From 7ee702c07bf606487984ea8f1be6ac2227428f54 Mon Sep 17 00:00:00 2001 From: "stephen@cubedesigners.com" Date: Fri, 22 Jul 2016 16:38:21 +0000 Subject: [PATCH] Integration of FullPage.js on home page. WIP #4 @5 --- .../views/helpers/ContactFooter.php | 2 +- .../application/views/helpers/HomeLayer.php | 3 +++ .../views/scripts/templates/home.phtml | 7 +++++- js/101-header.js | 5 ++++- js/210-home.js | 22 ++++++++++++++----- 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/framework/application/views/helpers/ContactFooter.php b/framework/application/views/helpers/ContactFooter.php index 2e90768..c56e975 100644 --- a/framework/application/views/helpers/ContactFooter.php +++ b/framework/application/views/helpers/ContactFooter.php @@ -21,6 +21,6 @@ class Fluidbook_View_Helper_ContactFooter extends CubeIT_View_Helper_Abstract { $res = $this->htmlElement($res, 'div', array('class' => 'grid')); $res = $this->backgroundBlock($res, $cf, array('content-wrapper')); - return $this->htmlElement($res, 'section', array('class' => 'contactFooter')); + return $this->htmlElement($res, 'section', array('class' => 'contactFooter section')); } } \ No newline at end of file diff --git a/framework/application/views/helpers/HomeLayer.php b/framework/application/views/helpers/HomeLayer.php index ca2cc7a..30a1a2a 100644 --- a/framework/application/views/helpers/HomeLayer.php +++ b/framework/application/views/helpers/HomeLayer.php @@ -4,6 +4,9 @@ class Fluidbook_View_Helper_HomeLayer extends CubeIT_View_Helper_Abstract { public $data; protected function _layer($content, $class, $attributes = array()) { + + $class .= ' section'; + $defaultAttributes = array('class' => $class, 'data-headerstyle' => $this->data['headerstyle']); $attributes = $this->_mergeAttributes($attributes, $defaultAttributes); diff --git a/framework/application/views/scripts/templates/home.phtml b/framework/application/views/scripts/templates/home.phtml index d8fed73..c2ef6ba 100644 --- a/framework/application/views/scripts/templates/home.phtml +++ b/framework/application/views/scripts/templates/home.phtml @@ -1,3 +1,8 @@ headScript()->addFullPage(); $this->headScript()->addScriptAndStyle('210-home'); -echo $this->home(); \ No newline at end of file + +echo '
'; // Needed because FullPage.js doesn't work when the wrapper is a
element +echo $this->home(); +echo '
'; \ No newline at end of file diff --git a/js/101-header.js b/js/101-header.js index 638b67e..4374131 100644 --- a/js/101-header.js +++ b/js/101-header.js @@ -116,10 +116,13 @@ function headerScroll() { } function changeHeaderStyle() { + + // Todo: rework all this to be compatible with FullPage.js - see callbacks... + var scrollTop = $(window).scrollTop(); var wh = $(window).height(); var section; - $('main>section').each(function () { + $('#home > section').each(function () { var offset = $(this).offset().top; if (scrollTop >= offset && scrollTop <= offset + wh - 50) { section = $(this); diff --git a/js/210-home.js b/js/210-home.js index 840496c..346f3ea 100644 --- a/js/210-home.js +++ b/js/210-home.js @@ -1,18 +1,28 @@ registerLoader(load_home, true); function load_home() { $(window).on('fluidbookresize', resizeHome); - resizeHome(); + + // FullPage.js setup + $('#home').fullpage({ + navigation: true, + navigationPosition: 'left', + verticalCentered: false + }); + } function resizeHome() { - // Resize sections - var wh = $(window).outerHeight() / zoom; - var ww = $(window).outerWidth() / zoom; - $('main>section').css('height', wh); + // Todo: see if this can be removed completely if FullPage.js handles the section sizing... - resizeHomeContact(ww, wh); + // Resize sections + // var wh = $(window).outerHeight() / zoom; + // var ww = $(window).outerWidth() / zoom; + // $('#home > section').css('height', wh); + // + // + // resizeHomeContact(ww, wh); } function resizeHomeContact(ww, wh) { -- 2.39.5