mirror of https://github.com/twbs/ratchet.git
Roi Avinoam
10 years ago
17 changed files with 308 additions and 6 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,47 @@
|
||||
/* ======================================================================== |
||||
* Ratchet: drawer.js v2.0.2 |
||||
* http://goratchet.com/components#drawer
|
||||
* ======================================================================== |
||||
* Copyright 2014 Connor Sears |
||||
* Licensed under MIT (https://github.com/twbs/ratchet/blob/master/LICENSE)
|
||||
* ======================================================================== */ |
||||
|
||||
!(function () { |
||||
'use strict'; |
||||
|
||||
var findDrawers = function (target) { |
||||
var i; |
||||
var drawers = document.querySelectorAll('a'); |
||||
|
||||
for (; target && target !== document; target = target.parentNode) { |
||||
for (i = drawers.length; i--;) { |
||||
if (drawers[i] === target) { |
||||
return target; |
||||
} |
||||
} |
||||
} |
||||
}; |
||||
|
||||
var getDrawer = function (event) { |
||||
var drawerToggle = findDrawers(event.target); |
||||
if (drawerToggle && drawerToggle.hash) { |
||||
return document.querySelector(drawerToggle.hash); |
||||
} |
||||
}; |
||||
|
||||
window.addEventListener('touchend', function (event) { |
||||
if (event.target.classList.contains('drawer')) { |
||||
// click directly on the drawer, but not on it's inner element
|
||||
event.target.classList.remove('active'); |
||||
return; |
||||
} |
||||
|
||||
var drawer = getDrawer(event); |
||||
if (drawer) { |
||||
if (drawer && drawer.classList.contains('drawer')) { |
||||
drawer.classList.toggle('active'); |
||||
} |
||||
event.preventDefault(); // prevents rewriting url (apps can still use hash values in url)
|
||||
} |
||||
}); |
||||
}()); |
@ -0,0 +1,38 @@
|
||||
// |
||||
// DRAWER |
||||
// -------------------------------------------------- |
||||
|
||||
|
||||
.drawer { |
||||
position: absolute; |
||||
padding: inherit; |
||||
top: 0; |
||||
left: -100%; |
||||
width: 100%; |
||||
height: 100%; |
||||
background-color: rgba(0,0,0,0); |
||||
|
||||
// wait for the drawer-inner animation to finish before hiding the backdrop |
||||
@include transition(background-color .25s linear, left 0 linear .25s); |
||||
} |
||||
|
||||
.drawer.active { |
||||
left: 0; |
||||
background-color: rgba(0,0,0,.3); |
||||
@include transition(background-color .25s linear); |
||||
} |
||||
|
||||
.drawer > .drawer-inner { |
||||
position: relative; |
||||
left: -100%; |
||||
width: 80%; |
||||
height: 100%; |
||||
background: white; |
||||
overflow: hidden; |
||||
@include box-shadow(1px 0 2px rgba(0,0,0,.3)); |
||||
@include transition(left .25s linear); |
||||
} |
||||
|
||||
.drawer.active > .drawer-inner { |
||||
left: 0; |
||||
} |
Loading…
Reference in new issue