1.0.4 • Published 2 years ago

mob-spy v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

mob-spy

npm.io

Install

npm install mob-spy

Usage

普通用法

import Mob from "mob-spy";

const mob = new Mob();

// log true in PC, and log false in mobile/ipad/pad
console.log(mob.getIsPc);

// log the orientation of the screen when it is in mobile/ipad/pad
// portrait or landscape
console.log(mob.getOrientation);

响应式用法

import Mob from "mob-spy";

const mob = new Mob();

window.onresize = () => {
  mob.onWindowResize();

  // log true in PC, and log false in mobile/ipad/pad
  console.log(mob.getIsPc);

  // log the orientation of the screen when it is in mobile/ipad/pad
  // portrait or landscape
  console.log(mob.getOrientation);
};

// 或者
window.addEventListener("resize", () => {
  mob.onWindowResize();

  // log true in PC, and log false in mobile/ipad/pad
  console.log(mob.getIsPc);

  // log the orientation of the screen when it is in mobile/ipad/pad
  // portrait or landscape
  console.log(mob.getOrientation);
}

Attributes

AttributeDescriptionTypeDefaultAvailable Vaules
getIsPca getter which indicates it is PC or mobileBooleantruetrue/false
getOrientationa getter which indicates the orientation of the screen in mobileString""portrait/landscape
onWindowResizefunction which responsively does detectionsFuntion--

License

MIT

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago