1 Star 1 Fork 0

theajack / landscape-simulator

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

LandscapeSimulator

star Author

Version Downloads Size License TopLang issue

🚀 横屏模拟器-在无法横屏的场景模拟横屏

在线体验 | English | 更新日志 | Issue | Gitee


展开目录

1. 特性

  1. typescript 编写
  2. 支持移动端竖屏旋转模拟横屏
  3. 获取模拟横屏状态与长宽

2. 快速使用

1.1 npm 方式

npm i landscape-simulator
import LandscapeSimulator from 'landscape-simulator';

LandscapeSimulator.init({
  disablePc: false, // 默认为true
})

推荐将上述初始化代码置于head中执行

1.2 cdn

使用cdn方式时,可将script标签放置在head中

<script src="https://cdn.jsdelivr.net/npm/landscape-simulator/landscape-simulator.min.js"></script>

可以使用属性 auto-simulate=false 来控制不要使用自动开启模拟,默认为自动开启。

可以使用属性 disable-pc=false 来控制在pc端也开启模拟,默认为在pc端不开启。

使用cdn方式引用时,会在window上挂载 LandscapeSimulator 对象

2 API

2.1 init

初始化模拟器,使用cdn方式引用时会自动初始化

LandscapeSimulator.init({
  disablePc: false, // 默认为true
})

2.2 appendChild

往旋转容器中添加子元素

LandscapeSimulator.appendChild(htmlElement);

2.3 getSimulateSize

获取模拟的过后的屏幕尺寸

const size = LandscapeSimulator.getSimulateSize();

2.4 isSimulateLandscape

获取当前是否处于模拟横屏的状态

const bool = LandscapeSimulator.isSimulateLandscape();

2.5 onSimulateChange

监听模拟横屏状态改变

LandscapeSimulator.onSimulateChange(isSimulate => {
  
});
The MIT License (MIT) Copyright (c) 2019 - present Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Simulate landscape in scenes that cannot be landscaped 展开 收起
JavaScript 等 3 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/theajack/landscape-simulator.git
git@gitee.com:theajack/landscape-simulator.git
theajack
landscape-simulator
landscape-simulator
master

搜索帮助