UNPKG

este-library-oldschool

Version:

Library for github.com/steida/este.git

92 lines (85 loc) 2.62 kB
// Generated by github.com/steida/coffee2closure 900.1.18 /** @fileoverview Simple view manager. It switches view elements without fancy animation. Use it for desktop or old mobile devices, where FX is slow and ```-webkit-overflow-scrolling: touch;``` does not work. */ var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.superClass_ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; goog.provide('este.app.screen.OneView'); goog.require('este.app.screen.Base'); goog.require('goog.dom'); goog.require('goog.dom.classlist'); goog.require('goog.userAgent'); /** @param {boolean} scrollingOnHistory @constructor @extends {este.app.screen.Base} */ este.app.screen.OneView = function(scrollingOnHistory) { this.scrollingOnHistory = scrollingOnHistory; este.app.screen.OneView.superClass_.constructor.call(this); goog.dom.classlist.add(document.documentElement, 'e-app-screen-oneview'); } extend(este.app.screen.OneView, superClass); /** @type {boolean} @protected */ este.app.screen.OneView.prototype.scrollingOnHistory = true; /** @override */ este.app.screen.OneView.prototype.enterDocument = function() { este.app.screen.OneView.superClass_.enterDocument.call(this); if (this.scrollingOnHistory) { this.on(window, 'scroll', this.onWindowScroll); } }; /** @param {goog.events.BrowserEvent} e @protected */ este.app.screen.OneView.prototype.onWindowScroll = function(e) { if (!this.currentView) { return; } return this.currentView.scroll = goog.dom.getDocumentScroll(); }; /** @param {boolean} isNavigation @protected */ este.app.screen.OneView.prototype.updateScroll = function(isNavigation) { var update; update = (function(_this) { return function() { if (isNavigation && _this.currentView.scroll) { return window.scrollTo(_this.currentView.scroll.x, _this.currentView.scroll.y); } else { return _this.scrollTo(0, 0); } }; })(this); if (goog.userAgent.MOBILE) { return setTimeout(update, 0); } else { return update(); } }; /** @override */ este.app.screen.OneView.prototype.show = function(view, isNavigation) { this.removePreviousView(); this.setCurrentView(view); this.lazyRenderView(); this.rememberPreviousView(); return this.updateScroll(isNavigation); }; /** @override */ este.app.screen.OneView.prototype.hide = function(view) { return view.exitDocument(); };