skel doc

2018-01-23  本文已影响0人  雨和眼泪

Skel

Skel is a lightweight framework for building responsive sites and web apps. Features include:
skel是一个轻量级的构建响应式页面的框架,特点包括:

Usage-使用方法

Load skel.min.js (either in your <head> tag or before </body> -- doesn't matter) to create the global skel object:
加载skel.min.js,无论在head标签中还是body标签中都不要紧,

<script src="skel.min.js"></script>

Then use skel.breakpoints() to define your breakpoints (each consisting of a name and a media query):
然后使用skel.breakpoints()方法来明确你的断点,(可以由 name 或者以媒体查询组成)

skel.breakpoints({
    xlarge: "(max-width: 1680px)",
    large:  "(max-width: 1280px)",
    medium: "(max-width: 980px)",
    small:  "(max-width: 736px)",
    xsmall: "(max-width: 480px)"
});

That's pretty much it. You can now do stuff like:
差不多就是这个样子了,你可以想下面这样做一些事情了:

skel
    .on("ready", function() {

        /* do DOM ready stuff
            做DOM准备工作
         */

        if (skel.breakpoint("small").active) {
            /* do something specific for small displays
                做一些为小型显示器特定的一些工作
             */
        }

        if (skel.vars.touch) {
            /* enable feature for devices with a touchscreen
                为触摸设备写一些特征
             */
        }

        if (skel.vars.IEVersion < 9) {
            /* apply workaround for IE<9
                针对IE9写的一些方法
             */
        }

    })
    .on("+large", function() {
        /* do something when "large" breakpoint becomes active
        当large断点变活跃时要做的事
         */
    })
    .on("-large !large", function() {
        /* do something when "large" breakpoint is (or becomes) inactive 
        做一些事情当large断点为活跃或者要抵达这个断点的时候*/
    });

Breakpoints-断点是什么?

Skel's primary feature is its ability to make CSS breakpoints accessible via JS. To set this up, simply call skel.breakpoints() with a list of media queries (presumably mirroring those found in your CSS) in the following format:
skel主要的特称是通过js来控制css的断点,通过简单的调用skel.breakpoints(),传递一个媒体查询列表来设置断点,格式如下

skel.breakpoints({
    name: "media query",
    name: "media query",
    name: "media query",
    ...
});

Where name is a unique identifier for each breakpoint (eg. medium). For example, the following defines 5 breakpoints (xlarge, large, medium, small, and xsmall):

skel.breakpoints({
    xlarge: "(max-width: 1680px)",
    large:  "(max-width: 1280px)",
    medium: "(max-width: 980px)",
    small:  "(max-width: 736px)",
    xsmall: "(max-width: 480px)"
});

With these in place, individual breakpoint objects can be retrieved using skel.breakpoint(), for example:
在这些地方, 私有的断点对象可以检索到断点,使用skel.breakpoint(),例如:

// Get the "small" breakpoint object. 获取small这个断点的对象
var x = skel.breakpoint("small");

Breakpoint objects have the following properties:
断点对象有下面这些属性,active、wasActive、name、media

Events-- 事件

Skel provides a small set of common and breakpoint-oriented events. Handlers can be bound to these events using skel.on(), like so:

skel.on("event", function() {
    /* do stuff */
});

You can also bind a single handler to multiple events by providing them in a space-delimited list:

skel.on("event1 event2 ...", function() {
    /* do stuff */
});

The following events are currently supported:

Vars

Skel exposes basic information about the client (such as its browser and operating system) through the skel.vars property. For example:

alert("Your browser is " + skel.vars.browser);

This information can, among other things, be used to apply browser (and even operating system) specific workarounds for those rare but frustratingly annoying moments where feature detection fails. The following vars are currently available:

Credits

License

Skel is released under the MIT license.

Copyright (c) skel.io

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.

上一篇 下一篇

猜你喜欢

热点阅读