npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tingle-context

v1.0.1

Published

Tingle Context

Downloads

45

Readme

Context

tingle的上下文模块,提供全局性的属性和方法。

手势事件去差异

  • TOUCH_START:移动端的值是touchstart,PC端的值是mousedown
  • TOUCH_MOVE:移动端的值是touchmove,PC端的值是mousemove
  • TOUCH_END:移动端的值是touchend,PC端的值是mouseup
  • TOUCH_CANCEL:移动端的值是touchcancel,PC端的值是mouseup

是什么环境

  • isMobile:boolean,是否是运行在移动端,目前没有区分padpad环境下该值为true
  • isPC:boolean,是否是运行在PC端

是否支持

  • support3D:是否支持css硬件加速
  • supportHairline:是否支持0.5px的细线
  • supportTouch:是否支持移动端手势

getTID

获取自增长的id

Context.getTID(); // 0
Context.getTID(); // 1

mixin

合并对象,功能同jQueryextend

var obj = Context.mixin({name:'tingle'}, {age:'1'});
// obj === {'name':'tingle', 'age':'1'}

noop

空函数,常用于回调函数的默认函数


TextField.defaultProps = {
    onChange: Context.noop
}

rem(px, artBoardWidth)

px单位的值转换为rem单位的值。

参数:

  • px:{Number},必选项。表示要被转换的值。
  • artBoardWidth:{Number},可选。计算rem时要基于的画板宽度,即设计稿的实际宽度,默认750px

使用:

Context.rem(750); // 基于`750px`的设计稿,`750px`等于`10rem`
Context.rem(750, 640); // 基于`640px`的设计稿,`750px`等于`11.71875rem`

makePrivateRem(artBoardWidth)

以指定画板宽度(artBoardWidth)创建私有的rem方法。

参数:

  • artBoardWidth:{Number},可选。计算rem时要基于的画板尺寸,即设计稿的实际尺寸。

使用:

var Context = require('tingle-context');
var privateRem = Context.makePrivateRem(640); // 创建基于`640px`宽的`rem`方法
privateRem(750); // 基于`640px`的设计稿,`750px`等于`11.71875rem`

// 默认的`rem`方法是基于`750px`宽的设计稿
Context.rem(750); // 10rem

TODOs

  • 添加set方法,用于全局配置tingle的运行环境。如Tingle.set('artBoardWidth', 640)

updates

v1.0.1

  • 保证require方式引用时返回的是同一个上下文对象

v1.0.0

  • 将react从0.13.3升级到0.14.3
  • 删除React.initializeTouchEvents

v0.1.5

  • html上添加dpr类值

v0.1.0 (2015-08-25)

  • ES6化。
  • 简化环境判断的层级,如:Context.is.pc改为Context.isPC

v0.0.4 (2015-08-18)

  • 0.5px支持,在html元素的class中以hairline标识。
  • 无入侵的rem方案支持,添加rem方法和makePrivateRem方法。

v0.0.3 (2015-07-14)

  • 添加文档