Giter Site home page Giter Site logo

npm-forced-original-scale's Introduction

Forced original scale

About:

Is the site or web application displayed incorrectly due to scaling set by the operating system? This package will solve your problem. It doesn't matter what percentage your page scaling by system is - it will be displayed at the correct scale

RU: Описание на русском языке внизу страницы. Этот пакет поможет вашему сайту всегда отображаться в правильном масштабе.

How to use

Install the package: npm install forced-original-scale

Clean HTML+JS without WebPack:

Before using npm-package in a clean HTML+JS or PHP, you need to compile a bundle from it. It's very simple, follow the instructions:

  1. Install browserify first: npm i -g browserify (in the console, the root folder of the project)
  2. Create an "index.js" file in the root folder and write in it var originalScale = require('forced-original-scale');
  3. Build bundle using browserify: browserify index.js > bundle.js (in the console, the root folder of the project)
  4. In your index.html, before the closing "body" tag, add:

<script src="bundle.js"></script><script>document.addEventListener("DOMContentLoaded", function() { window.originalScale('container'); } );</script> where "container" is main container with all your pages, like <div id="container">...your html...</div> (you can name it whatever you want, as long but it want to be the id of the main component)

Using React:

1. Import the module into your App.jsx

import originalScale from 'forced-original-scale';

2. Call the module when the main component is ready

if you use hooks: useEffect(() => { originalScale('App'); }, [] );

if you use classes: componentDidMount() { originalScale('App'); };

where "App" is main container with all your pages, like <div id="App">.....</div> (you can name it whatever you want, as long but it want to be the id of the main component)


RU

О пакете:

Сайт или веб-приложение отображается неправильно из-за масштабирования, установленного операционной системой? Этот модуль решит вашу проблему. Неважно, какой процент масштабирования вашей страницы системой - он будет отображаться в правильном масштабе.

Как использовать

Установите пакет: npm install forced-original-scale

Чистый HTML+JS:

Чтобы использовать npm-модуль в чистом HTML+JS или PHP, вам необходимо собрать его при помощи browserify в бандл. Это очень просто, следуйте инструкции:

  1. Сначала установите browserify: npm i -g browserify (в консоли, корневая папка проекта)
  2. Создайте в корневой папке проекта файл index.js и напишите внутри него:
    var originalScale = require('forced-original-scale');
  3. Выполните сборку при помощи browserify: browserify index.js > bundle.js (в консоли, корневая папка проекта)
  4. Далее в вашем index.html перед закрывающимся тэгом body добавьте:

<script src="bundle.js"></script><script>document.addEventListener("DOMContentLoaded", function() { window.originalScale('container'); } );</script> где "container" это ID главного контейнера, в котором находится весь ваш HTML-код

Пример: <div id="container">...ваш html...</div> (вы можете назвать его как угодно, главное чтобы это был именно id контейнера внутри которого всё находится)

Используя React:

1. Добавьте в ваш App.jsx импорт модуля

import originalScale from 'forced-original-scale';

2. Вызовите модуль, когда главный компонент будет отрисован

Если вы используете хуки: useEffect(() => { originalScale('App'); }, [] );

Если вы предпочитаете классы: componentDidMount() { originalScale('App'); };

где "App" это ID главного контейнера, в котором находится всё ваше приложение.

Пример: <div id="App">.....</div> (вы можете назвать его как угодно, главное чтобы это был именно id контейнера внутри которого всё находится)

npm-forced-original-scale's People

Contributors

rikkster avatar

Stargazers

Mike Dmitrievskiy avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.