Shifter Demo
57 | 58 |59 | View Documentation 60 |
Basic
66 |Shifter works by checking for target elements in the DOM and binding events to them. This allows you to markup and style pages anyway you'd like, but at a minimum you need three specifically classed elements (including the body tag):
$.shifter();
69 | <body class="shifter">
70 | <div class="shifter-page">
71 | <span class="shifter-handle">Menu</span>
72 | <!-- Page Content -->
73 | </div>
74 | <nav class="shifter-navigation">
75 | <!-- Navigation -->
76 | </nav>
77 | </body>
78 |
79 |
83 |
84 |
85 | Breakpoint
86 |By default, Shifter will enable itself on screens smaller then 980 pixels wide. You can specify a different width by setting the maxWidth option on initialization.
$.shifter({
89 | maxWidth: Infinity
90 | });
91 |
92 | Demo
93 |Click or tap the handle at the top-right of this page!
94 |95 | 96 | 97 |
IE Support
98 |When supporting IE you will need to include a HTML5 enabler and matchMedia polyfill (IE 8, IE 9).
99 | 100 | 101 | 102 |
4 | # Shifter
5 |
6 | A jQuery plugin for simple slide-out mobile navigation. Part of the Formstone Library.
7 |
8 | - [Demo](http://classic.formstone.it/components/Shifter/demo/index.html)
9 | - [Documentation](http://classic.formstone.it/shifter/)
10 |
11 | #### Bower Support
12 | `bower install Shifter`
--------------------------------------------------------------------------------
/src/jquery.fs.shifter-config.less:
--------------------------------------------------------------------------------
1 |
2 | // Use these variables when compiling directly
3 |
4 | @shifter-transition-speed: 0.2s; // 0.2s
5 | @shifter-transition-timing: ease; // ease
6 |
7 | // Nav
8 |
9 | @shifter-nav-background: #fff; // #fff
10 | @shifter-nav-width: 270px; // 270px
11 |
12 | // Page
13 |
14 | @shifter-page-background: #fff; // #fff
15 | @shifter-page-box-shadow-color: rgba(0, 0, 0, 0.15); // rgba(0, 0, 0, 0.15)
16 | @shifter-page-box-shadow-blur: 2px; // 2px
17 |
18 | // Handle
19 |
20 | @shifter-handle-background: #fff; // #fff
21 | @shifter-handle-height: 30px; // 30px
22 | @shifter-handle-width: 30px; // 30px
23 |
24 | // Handle Icon
25 |
26 | @shifter-icon-color: #666; // #666
27 | @shifter-icon-height: 3px; // 3px
28 | @shifter-icon-width: 20px; // 20px
--------------------------------------------------------------------------------
/shifter.jquery.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "shifter",
3 | "version": "3.1.2",
4 | "title": "Shifter",
5 | "author": {
6 | "name": "Ben Plum",
7 | "email": "mr@benplum.com",
8 | "url": "http://www.benplum.com"
9 | },
10 | "licenses": [
11 | {
12 | "type": "MIT",
13 | "url": "http://opensource.org/licenses/MIT"
14 | }
15 | ],
16 | "dependencies": {
17 | "jquery": ">=1.7"
18 | },
19 | "description": "A jQuery plugin for simple slide-out mobile navigation. Part of the Formstone Library.",
20 | "keywords": [
21 | "responsive",
22 | "mobile",
23 | "navigation",
24 | "menu",
25 | "ui",
26 | "javascript",
27 | "jquery",
28 | "formstone"
29 | ],
30 | "docs": "http://classic.formstone.it/shifter/",
31 | "demo": "http://classic.formstone.it/shifter/",
32 | "download": "https://github.com/FormstoneClassic/Shifter",
33 | "bugs": "https://github.com/FormstoneClassic/Shifter/issues",
34 | "homepage": "http://classic.formstone.it/shifter/"
35 | }
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright 2015 Ben Plum
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Shifter",
3 | "id": "shifter",
4 | "codename": "jquery.fs.shifter",
5 | "version": "3.1.2",
6 | "description": "A jQuery plugin for simple slide-out mobile navigation. Part of the Formstone Library.",
7 | "keywords": [
8 | "responsive",
9 | "mobile",
10 | "navigation",
11 | "menu",
12 | "ui",
13 | "javascript",
14 | "jquery",
15 | "formstone"
16 | ],
17 | "repository": {
18 | "type": "git",
19 | "url": "https://github.com/FormstoneClassic/Shifter"
20 | },
21 | "homepage": "http://classic.formstone.it/shifter/",
22 | "demo": "http://classic.formstone.it/components/Shifter/demo/index.html",
23 | "license": "MIT",
24 | "author": {
25 | "name": "Ben Plum",
26 | "email": "mr@benplum.com",
27 | "url": "http://www.benplum.com"
28 | },
29 | "devDependencies": {
30 | "grunt": "~0.4.2",
31 | "grunt-autoprefixer": "^1.0.1",
32 | "grunt-banner": "^0.2.3",
33 | "grunt-contrib-copy": "^0.6.0",
34 | "grunt-contrib-jshint": "~0.7.2",
35 | "grunt-contrib-less": "^0.11.4",
36 | "grunt-contrib-uglify": "~0.2.7",
37 | "grunt-contrib-watch": "^0.6.1",
38 | "grunt-jquerymanifest": "~0.1.3",
39 | "grunt-npm2bower-sync": "~0.3.0"
40 | }
41 | }
--------------------------------------------------------------------------------
/jquery.fs.shifter.min.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Shifter v3.1.2 - 2015-04-04
3 | * A jQuery plugin for simple slide-out mobile navigation. Part of the Formstone Library.
4 | * http://classic.formstone.it/shifter/
5 | *
6 | * Copyright 2015 Ben Plum; MIT Licensed
7 | */
8 |
9 | !function(a,b){"use strict";function c(c){i||(k=a.extend({},s,c||{}),k.$html=a("html"),k.$body=a("body"),k.$shifts=a([g(m),g(n)].join(", ")),k.$nav=a(g(o)),k.$shifts.length>0&&k.$nav.length>0&&(i=!0,k.$body.on(r,g(l),e),void 0!==b.matchMedia&&(k.mediaQuery=b.matchMedia("(max-width:"+(k.maxWidth===1/0?"100000px":k.maxWidth)+")"),k.mediaQuery.addListener(d),d())))}function d(){k.mediaQuery.matches?t.enable():t.disable()}function e(a){a.preventDefault(),a.stopPropagation(),j||(k.$body.hasClass(q)?t.close():t.open()),"touchstart"===a.type&&(j=!0,setTimeout(f,500))}function f(){j=!1}function g(a){return"."+a}var h="shifter",i=!1,j=!1,k={},l=h+"-handle",m=h+"-page",n=h+"-header",o=h+"-navigation",p=h+"-enabled",q=h+"-open",r="touchstart."+h+" click."+h,s={maxWidth:"980px"},t={close:function(){i&&(k.$html.removeClass(q),k.$body.removeClass(q),k.$shifts.off(g(h)),k.$nav.find("input").trigger("blur"))},enable:function(){i&&k.$body.addClass(p)},destroy:function(){i&&(k.$html.removeClass(q),k.$body.removeClass([p,q].join(" ")).off(r),void 0!==b.matchMedia&&k.mediaQuery.removeListener(d),k={},i=!1)},disable:function(){i&&(t.close(),k.$body.removeClass(p))},open:function(){i&&(k.$html.addClass(q),k.$body.addClass(q),k.$shifts.one(r,e))}};a[h]=function(a){return t[a]?t[a].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof a&&a?this:c.apply(this,arguments)}}(jQuery,window);
--------------------------------------------------------------------------------
/jquery.fs.shifter.min.css:
--------------------------------------------------------------------------------
1 | /*
2 | * Shifter v3.1.2 - 2015-04-04
3 | * A jQuery plugin for simple slide-out mobile navigation. Part of the Formstone Library.
4 | * http://classic.formstone.it/shifter/
5 | *
6 | * Copyright 2015 Ben Plum; MIT Licensed
7 | */
8 |
9 | .shifter-open{overflow:hidden}.shifter-open .shifter-page *,.shifter-open .shifter-header *{pointer-events:none}.shifter-navigation{display:none;opacity:0}.shifter-handle{display:none}.shifter-enabled .shifter-page{min-height:100%;position:relative;z-index:1;background:#fff;box-shadow:2px 0 2px rgba(0,0,0,.15);display:block;overflow:hidden}.shifter-enabled.shifter-left .shifter-page{box-shadow:-2px 0 2px rgba(0,0,0,.15)}.shifter-enabled .shifter-navigation{width:270px;height:100%;position:fixed;top:0;z-index:0;background:#fff;display:block;overflow:auto;pointer-events:none;-webkit-transition:opacity .001s linear .2s,-webkit-transform .2s ease;transition:opacity .001s linear .2s,transform .2s ease}.shifter-enabled .shifter-page,.shifter-enabled .shifter-header,.shifter-enabled .shifter-navigation{-webkit-backface-visibility:hidden;backface-visibility:hidden}.shifter-enabled .shifter-page,.shifter-enabled .shifter-header{-webkit-transform:translate3D(0,0,0);-ms-transform:translate3D(0,0,0);transform:translate3D(0,0,0);-webkit-transition:-webkit-transform .2s ease;transition:transform .2s ease}.shifter-enabled .shifter-handle{width:30px;height:30px;position:relative;background:#fff;cursor:pointer;display:block;overflow:hidden;text-indent:200%;white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.shifter-enabled .shifter-handle:after{height:3px;width:20px;position:absolute;top:0;right:0;bottom:0;left:0;background:#666;box-shadow:0 5px 0 #666,0 -5px 0 #666;content:'';display:block;margin:auto}.shifter-enabled .shifter-navigation{right:0;-webkit-transform:translate3D(0,0,0);-ms-transform:translate3D(0,0,0);transform:translate3D(0,0,0)}.shifter-open .shifter-page,.shifter-open .shifter-header{-webkit-transform:translate3D(-270px,0,0);-ms-transform:translate3D(-270px,0,0);transform:translate3D(-270px,0,0)}.shifter-enabled.shifter-left .shifter-navigation{left:0;-webkit-transform:translate3D(0,0,0);-ms-transform:translate3D(0,0,0);transform:translate3D(0,0,0)}.shifter-enabled.shifter-left.shifter-open .shifter-page,.shifter-enabled.shifter-left.shifter-open .shifter-header{-webkit-transform:translate3D(270px,0,0);-ms-transform:translate3D(270px,0,0);transform:translate3D(270px,0,0)}.shifter-open .shifter-navigation{opacity:1;pointer-events:all;-webkit-transform:translate3D(0,0,0);-ms-transform:translate3D(0,0,0);transform:translate3D(0,0,0);-webkit-transition:opacity .001s linear 0s,-webkit-transform .2s ease;transition:opacity .001s linear 0s,transform .2s ease}.no-csstransforms3d .shifter-enabled.shifter-navigation{right:-270px}.no-csstransforms3d .shifter-enabled.shifter-left .shifter-navigation{left:-270px}.no-csstransforms3d .shifter-enabled.shifter-open .shifter-page{left:-270px}.no-csstransforms3d .shifter-enabled.shifter-open .shifter-navigation{right:0}.no-csstransforms3d .shifter-enabled.shifter-left.shifter-open .shifter-page{left:auto;right:-270px}.no-csstransforms3d .shifter-enabled.shifter-left.shifter-open .shifter-navigation{left:0}
--------------------------------------------------------------------------------
/src/jquery.fs.shifter-styles.less:
--------------------------------------------------------------------------------
1 |
2 | .shifter {
3 | &-open {
4 | overflow: hidden;
5 | }
6 |
7 | &-open &-page *,
8 | &-open &-header * {
9 | pointer-events: none;
10 | }
11 |
12 | // default
13 |
14 | &-navigation {
15 | display: none;
16 | opacity: 0;
17 | }
18 |
19 | &-handle {
20 | display: none;
21 | }
22 |
23 | // enabled
24 |
25 | &-enabled &-page {
26 | min-height: 100%;
27 |
28 | position: relative;
29 | z-index: 1;
30 |
31 | background: @shifter-page-background;
32 | box-shadow: @shifter-page-box-shadow-blur 0 @shifter-page-box-shadow-blur @shifter-page-box-shadow-color;
33 | display: block;
34 | overflow: hidden;
35 | }
36 |
37 | &-enabled&-left &-page {
38 | box-shadow: -(@shifter-page-box-shadow-blur) 0 @shifter-page-box-shadow-blur @shifter-page-box-shadow-color;
39 | }
40 |
41 | &-enabled &-navigation {
42 | width: @shifter-nav-width;
43 | height: 100%;
44 |
45 | position: fixed;
46 | top: 0;
47 | z-index: 0;
48 |
49 | background: @shifter-nav-background;
50 | display: block;
51 | // opacity: 1;
52 | overflow: auto;
53 | pointer-events: none;
54 | transition:
55 | opacity 0.001s linear @shifter-transition-speed, // delay when closing
56 | transform @shifter-transition-speed @shifter-transition-timing;
57 | }
58 |
59 | &-enabled &-page,
60 | &-enabled &-header,
61 | &-enabled &-navigation {
62 | backface-visibility: hidden;
63 | }
64 |
65 | &-enabled &-page,
66 | &-enabled &-header {
67 | transform: translate3D(0, 0, 0);
68 | transition: transform @shifter-transition-speed @shifter-transition-timing;
69 | }
70 |
71 | &-enabled &-handle {
72 | width: @shifter-handle-width;
73 | height: @shifter-handle-height;
74 |
75 | position: relative;
76 |
77 | background: @shifter-handle-background;
78 | cursor: pointer;
79 | display: block;
80 | overflow: hidden;
81 | text-indent: 200%;
82 | white-space: nowrap;
83 | user-select: none;
84 |
85 | &:after {
86 | height: @shifter-icon-height;
87 | width: @shifter-icon-width;
88 |
89 | position: absolute;
90 | top: 0;
91 | right: 0;
92 | bottom: 0;
93 | left: 0;
94 |
95 | background: @shifter-icon-color;
96 | box-shadow:
97 | 0 (@shifter-icon-height + 2) 0 @shifter-icon-color,
98 | 0 -(@shifter-icon-height + 2) 0 @shifter-icon-color;
99 | content: '';
100 | display: block;
101 | margin: auto;
102 | }
103 | }
104 |
105 | // right (default)
106 |
107 | &-enabled &-navigation {
108 | right: 0;
109 |
110 | transform: translate3D(0, 0, 0);
111 | }
112 |
113 | &-open &-page,
114 | &-open &-header {
115 | transform: translate3D(-(@shifter-nav-width), 0, 0);
116 | }
117 |
118 | // left
119 |
120 | &-enabled&-left &-navigation {
121 | left: 0;
122 |
123 | transform: translate3D(0, 0, 0);
124 | }
125 |
126 | &-enabled&-left&-open &-page,
127 | &-enabled&-left&-open &-header {
128 | transform: translate3D(@shifter-nav-width, 0, 0);
129 | }
130 |
131 | // open
132 | &-open &-navigation {
133 | opacity: 1;
134 | pointer-events: all;
135 | transform: translate3D(0, 0, 0);
136 | transition:
137 | opacity 0.001s linear 0s, // no delay when opening
138 | transform @shifter-transition-speed @shifter-transition-timing;
139 | }
140 |
141 |
142 | // IE8 / 9 - no 3d transforms
143 |
144 | .no-csstransforms3d &-enabled&-navigation {
145 | right: -@shifter-nav-width;
146 | }
147 |
148 | // left
149 |
150 | .no-csstransforms3d &-enabled&-left &-navigation {
151 | left: -@shifter-nav-width;
152 | }
153 |
154 | // open
155 |
156 | .no-csstransforms3d &-enabled&-open &-page {
157 | left: -@shifter-nav-width;
158 | }
159 |
160 | .no-csstransforms3d &-enabled&-open &-navigation {
161 | right: 0;
162 | }
163 |
164 | // open left
165 |
166 | .no-csstransforms3d &-enabled&-left&-open &-page {
167 | left: auto;
168 | right: -@shifter-nav-width;
169 | }
170 |
171 | .no-csstransforms3d &-enabled&-left&-open &-navigation {
172 | left: 0;
173 | }
174 |
175 | }
--------------------------------------------------------------------------------
/demo/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |