Browse Source

handle toggle only on load and scroll.

pull/249/head
connors 11 years ago
parent
commit
a129448ff9
  1. 12
      docs-assets/css/docs.css
  2. 41
      docs-assets/js/docs.js
  3. 12
      lib/sass/docs.scss

12
docs-assets/css/docs.css

@ -899,24 +899,24 @@ body {
.platform-toggle .segmented-controller { .platform-toggle .segmented-controller {
max-width: 300px; max-width: 300px;
margin: 0 auto; margin: 0 auto;
border-color: #fff; border-color: #00d1fe;
background-color: transparent; background-color: transparent;
} }
.platform-toggle .segmented-controller li { .platform-toggle .segmented-controller li {
cursor: pointer; cursor: pointer;
border-color: #fff; border-color: #00d1fe;
} }
.platform-toggle .segmented-controller li a { .platform-toggle .segmented-controller li a {
color: #fff; color: #00d1fe;
} }
.platform-toggle .segmented-controller li:active { .platform-toggle .segmented-controller li:active {
background-color: rgba(255, 255, 255, 0.3); background-color: rgba(0, 209, 254, 0.3);
} }
.platform-toggle .segmented-controller li.selected { .platform-toggle .segmented-controller li.selected {
background-color: #fff; background-color: #00d1fe;
} }
.platform-toggle .segmented-controller li.selected a { .platform-toggle .segmented-controller li.selected a {
color: #254456; color: #fff;
} }
.component { .component {

41
docs-assets/js/docs.js

@ -15,14 +15,13 @@ $(function() {
var topCache; var topCache;
var eventListeners; var eventListeners;
var initialize = function () { var initialize = function () {
currentActive = 0; currentActive = 0;
topCache = []; topCache = [];
win = $(window); win = $(window);
doc = $(document); doc = $(document);
bod = $(document.body) bod = $(document.body)
device = device || $('.device'); device = device || $('.device');
platformToggle = $('.platform-toggle');
navComponentLinks = $('.docs-nav'); navComponentLinks = $('.docs-nav');
componentsList = $('.components-list'); componentsList = $('.components-list');
componentLinks = $('.component-example a'); componentLinks = $('.component-example a');
@ -38,10 +37,6 @@ $(function() {
device.initialTop = device.initialTop || device.offset().top; device.initialTop = device.initialTop || device.offset().top;
device.dockingOffset = ($(window).height() - device.height())/2; device.dockingOffset = ($(window).height() - device.height())/2;
// Toggle placment
toggleTop = platformToggle.offset().top;
toggleHeight = platformToggle.outerHeight();
checkDesktopContent(); checkDesktopContent();
calculateScroll(); calculateScroll();
@ -87,6 +82,7 @@ $(function() {
}); });
win.on('scroll', calculateScroll); win.on('scroll', calculateScroll);
win.on('scroll', calculateToggle);
} }
var checkDesktopContent = function () { var checkDesktopContent = function () {
@ -115,14 +111,6 @@ $(function() {
device[0].setAttribute('style','') device[0].setAttribute('style','')
} }
if(currentTop >= toggleTop) {
platformToggle.addClass('fixed');
$('.docs-components').css('padding-top', toggleHeight);
} else if (currentTop <= $('.docs-header').outerHeight()) {
platformToggle.removeClass('fixed');
$('.docs-components').css('padding-top', 0);
}
// Injection of components into device // Injection of components into device
for (var l = contentSection.length; l--;) { for (var l = contentSection.length; l--;) {
if ((topCache[l] - currentTop) < windowHeight) { if ((topCache[l] - currentTop) < windowHeight) {
@ -148,6 +136,31 @@ $(function() {
} }
} }
// Platform toggle
var initializeToggle = function () {
platformToggle = $('.platform-toggle');
// Toggle placment
toggleTop = platformToggle.offset().top;
toggleHeight = platformToggle.outerHeight();
calculateToggle();
}
var calculateToggle = function () {
var currentTop = win.scrollTop();
console.log('yep');
if(currentTop >= toggleTop) {
platformToggle.addClass('fixed');
$('.docs-components').css('padding-top', toggleHeight);
} else if (currentTop <= $('.docs-header').outerHeight()) {
platformToggle.removeClass('fixed');
$('.docs-components').css('padding-top', 0);
}
}
$(window).on('load resize', initialize); $(window).on('load resize', initialize);
$(window).on('load', initializeToggle);
$(window).on('load', function () { new FingerBlast('.device-content'); }); $(window).on('load', function () { new FingerBlast('.device-content'); });
}); });

12
lib/sass/docs.scss

@ -312,24 +312,24 @@ body {
.segmented-controller { .segmented-controller {
max-width: 300px; max-width: 300px;
margin: 0 auto; margin: 0 auto;
border-color: #fff; border-color: #00d1fe;
background-color: transparent; background-color: transparent;
li { li {
cursor: pointer; cursor: pointer;
border-color: #fff; border-color: #00d1fe;
a { a {
color: #fff; color: #00d1fe;
} }
&:active { &:active {
background-color: rgba(255,255,255,.3); background-color: rgba(0,209,254,.3);
} }
&.selected { &.selected {
background-color: #fff; background-color: #00d1fe;
a { a {
color: #254456; color: #fff;
} }
} }
} }

Loading…
Cancel
Save