/** * Modules in this bundle * @license * * pretty-scroll: * license: appleple * author: appleple * homepage: http://developer.a-blogcms.jp * version: 1.1.5 * * es6-object-assign: * license: MIT (http://opensource.org/licenses/MIT) * author: Rubén Norte * homepage: https://github.com/rubennorte/es6-object-assign * version: 1.1.0 * * This header is generated by licensify (https://github.com/twada/licensify) */ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.PrettyScroll = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i'); this.beforeElement = this.targetElement.previousElementSibling; this.parentElement = this.targetElement.parentElement; this.parentElement.style.position = 'relative'; window.addEventListener('scroll', function () { _this.onScroll(); }); window.addEventListener('resize', function () { _this.onScroll(); }); } _createClass(PrettyScroll, [{ key: 'applyStyle', value: function applyStyle(style) { var target = this.targetElement; for (var key in style) { target.style[key] = style[key]; } } }, { key: 'onScroll', value: function onScroll() { var scroll = (0, _util.getScrollTop)(); var beforeElement = this.beforeElement, containerElement = this.containerElement, targetElement = this.targetElement, targetWidth = this.targetWidth, targetBoxSizing = this.targetBoxSizing; var _opt = this.opt, offsetTop = _opt.offsetTop, offsetBottom = _opt.offsetBottom, condition = _opt.condition, breakpoint = _opt.breakpoint; var windowHeight = window.innerHeight; var windowWidth = window.innerWidth; var thisHeight = (0, _util.outerHeight)(targetElement); var beforeBottom = (0, _util.getOffset)(beforeElement).top; var containerHeight = (0, _util.outerHeight)(containerElement); var containerDiffBottom = parseInt(getComputedStyle(containerElement).paddingBottom, 10); var containerOffset = (0, _util.getOffset)(containerElement).top; var containerBottom = containerHeight + containerOffset; var limitHeight = windowHeight > thisHeight ? thisHeight + offsetTop + offsetBottom : windowHeight; var offsetHeight = thisHeight - windowHeight; var beforeOffsetTop = beforeElement.offsetTop; var beforeOffsetLeft = beforeElement.offsetLeft; var beforeDiffTop = beforeBottom - containerOffset; var style = { position: 'static', width: targetWidth, boxSizing: targetBoxSizing }; if (!condition()) { beforeElement.style.height = '0px'; this.applyStyle(style); return; } if (breakpoint >= windowWidth) { beforeElement.style.height = '0px'; this.applyStyle(style); return; } if (scroll < beforeBottom - offsetTop) { beforeElement.style.height = '0px'; this.applyStyle(style); this.scrollOld = scroll; return; } style.width = beforeElement.offsetWidth + 'px'; style.boxSizing = 'border-box'; if (scroll + limitHeight + containerDiffBottom <= containerBottom) { this.scrollAmount += scroll - this.scrollOld; this.scrollOld = scroll; if (this.scrollAmount > offsetHeight + offsetBottom) { this.scrollAmount = offsetHeight + offsetBottom; } else if (this.scrollAmount < -offsetTop) { this.scrollAmount = -offsetTop; } if (this.scrollAmount === offsetHeight + offsetBottom || this.scrollAmount + offsetTop === 0) { style.position = 'fixed'; if (this.scrollAmount + offsetTop === 0 || thisHeight < windowHeight) { style.top = offsetTop + 'px'; } else { style.top = windowHeight - thisHeight - offsetBottom + 'px'; } style.left = (0, _util.getOffset)(beforeElement).left + 'px'; } else { style.position = 'absolute'; if (scroll - this.scrollAmount < beforeBottom) { style.top = beforeOffsetTop + 'px'; } else { style.top = scroll - this.scrollAmount - beforeBottom + 'px'; } style.left = beforeOffsetLeft + 'px'; } } else { style.position = 'absolute'; style.top = containerHeight - thisHeight - beforeDiffTop - containerDiffBottom - offsetBottom + 'px'; style.left = beforeOffsetLeft + 'px'; } if (style.position === 'absolute' || style.position === 'fixed') { beforeElement.style.height = thisHeight + 'px'; } this.applyStyle(style); } }]); return PrettyScroll; }(); exports.default = PrettyScroll; module.exports = exports['default']; },{"../lib/util":4,"es6-object-assign":1}],3:[function(require,module,exports){ 'use strict'; module.exports = require('./core/'); },{"./core/":2}],4:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var append = exports.append = function append(element, string) { var parser = new DOMParser(); var doc = parser.parseFromString(string, 'text/html'); element.appendChild(doc.querySelector('body').childNodes[0]); }; var prepend = exports.prepend = function prepend(element, string) { var parser = new DOMParser(); var doc = parser.parseFromString(string, 'text/html'); element.insertBefore(doc.querySelector('body').childNodes[0], element.firstChild); }; var getUniqId = exports.getUniqId = function getUniqId() { return (Date.now().toString(36) + Math.random().toString(36).substr(2, 5)).toUpperCase(); }; var remove = exports.remove = function remove(element) { if (element && element.parentNode) { element.parentNode.removeChild(element); } }; var addClass = exports.addClass = function addClass(element, className) { if (element.classList) { element.classList.add(className); } else { element.className += ' ' + className; } }; var triggerEvent = exports.triggerEvent = function triggerEvent(el, eventName, options) { var event = void 0; if (window.CustomEvent) { event = new CustomEvent(eventName, { cancelable: true }); } else { event = document.createEvent('CustomEvent'); event.initCustomEvent(eventName, false, false, options); } el.dispatchEvent(event); }; var getScrollTop = exports.getScrollTop = function getScrollTop() { return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0; }; var getScrollLeft = exports.getScrollLeft = function getScrollLeft() { return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0; }; var getOffset = exports.getOffset = function getOffset(el) { var rect = el.getBoundingClientRect(); return { top: rect.top + getScrollTop(), left: rect.left + getScrollLeft() }; }; var before = exports.before = function before(el, html) { el.insertAdjacentHTML('beforebegin', html); }; var outerHeight = exports.outerHeight = function outerHeight(el) { var height = el.offsetHeight; var style = getComputedStyle(el); height += parseInt(style.marginTop) + parseInt(style.marginBottom); return height; }; var selfHeight = exports.selfHeight = function selfHeight(el) { var height = el.offsetHeight; var style = getComputedStyle(el); height -= parseInt(style.paddingTop) + parseInt(style.paddingBottom); return height; }; },{}]},{},[3])(3) });