summaryrefslogtreecommitdiff
path: root/public/bundle.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/bundle.js')
-rw-r--r--public/bundle.js201
1 files changed, 182 insertions, 19 deletions
diff --git a/public/bundle.js b/public/bundle.js
index ad63eec..ab8eac2 100644
--- a/public/bundle.js
+++ b/public/bundle.js
@@ -2489,10 +2489,14 @@ var _createClass = function () { function defineProperties(target, props) { for
var _preact = __webpack_require__(7);
+var _util = __webpack_require__(52);
+
var _db = __webpack_require__(21);
var _db2 = _interopRequireDefault(_db);
+var _lethargy = __webpack_require__(53);
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -2510,15 +2514,37 @@ var App = function (_Component) {
var _this = _possibleConstructorReturn(this, (App.__proto__ || Object.getPrototypeOf(App)).call(this));
_this.state = {
+ index: 0,
data: _db2.default.backupDB
};
+ _this.lastScroll = Date.now();
+ _this.onScroll = _this.onScroll.bind(_this);
+ _this.lethargy = new _lethargy.Lethargy(8, 100, 1.1, 1000);
_db2.default.fetch(function (data) {
- return _this.setState({ data: data });
+ document.body.parentNode.classList.remove('loading');
+ _this.setState({ data: data });
});
+ // document.body.addEventListener('mousewheel', this.onScroll)
+ // document.body.addEventListener('DOMMouseScroll', this.onScroll)
+ document.body.addEventListener('wheel', _this.onScroll);
return _this;
}
_createClass(App, [{
+ key: 'onScroll',
+ value: function onScroll(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ var scrollDirection = this.lethargy.check(e);
+ var now = Date.now();
+ if (scrollDirection !== false && now - this.lastScroll > 500) {
+ this.lastScroll = now;
+ var cellCount = this.state.data.painting.length;
+ var index = (this.state.index + cellCount - scrollDirection) % cellCount;
+ this.setState({ index: index });
+ }
+ }
+ }, {
key: 'render',
value: function render() {
var paintings = this.state.data.painting.map(function (painting, i) {
@@ -2533,24 +2559,30 @@ var App = function (_Component) {
(0, _preact.h)(
'div',
{ 'class': 'about' },
- (0, _preact.h)(
- 'div',
- { 'class': 'medium' },
- (0, _preact.h)(
- 'div',
- { 'class': 'title' },
- painting.title
- ),
- painting.medium,
- (0, _preact.h)('br', null),
- painting.date,
- (0, _preact.h)('br', null),
- painting.image.caption,
- (0, _preact.h)('br', null)
- )
+ painting.title,
+ (0, _preact.h)('br', null),
+ painting.medium,
+ (0, _preact.h)('br', null),
+ painting.date,
+ (0, _preact.h)('br', null),
+ painting.image.caption,
+ (0, _preact.h)('br', null)
)
);
});
+ var about = this.state.data.page[0];
+ var body = (about.body || '').replace(/\n/g, '<br>');
+ var page = (0, _preact.h)(
+ 'div',
+ { 'class': 'cell' },
+ (0, _preact.h)(
+ 'div',
+ { 'class': 'painting' },
+ (0, _preact.h)('div', { 'class': 'image', style: 'background-image: url(' + about.image.uri + ')' })
+ ),
+ (0, _preact.h)('div', { 'class': 'about', dangerouslySetInnerHTML: { __html: body } })
+ );
+ var scrollPercentage = this.state.index * -100;
return (0, _preact.h)(
'div',
null,
@@ -2561,8 +2593,11 @@ var App = function (_Component) {
),
(0, _preact.h)(
'div',
- { 'class': 'scroller' },
- paintings
+ { 'class': 'scroller',
+ style: 'transform:translateY(' + scrollPercentage + 'vh)'
+ },
+ paintings,
+ page
)
);
}
@@ -2614,7 +2649,8 @@ function parse(db) {
}
var backupDB = {
- painting: []
+ painting: [],
+ page: [{ image: { uri: 'about:blank' } }]
};
exports.default = { fetch: fetchDB, backupDB: backupDB };
@@ -5579,6 +5615,133 @@ NavLink.defaultProps = {
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return __WEBPACK_IMPORTED_MODULE_0_react_router__["i"]; });
+/***/ }),
+/* 52 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+var isIphone = navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i);
+var isIpad = navigator.userAgent.match(/iPad/i);
+var isAndroid = navigator.userAgent.match(/Android/i);
+var isMobile = isIphone || isIpad || isAndroid;
+var isDesktop = !isMobile;
+
+document.body.classList.add(isDesktop ? 'desktop' : 'mobile');
+
+exports.default = { isIphone: isIphone, isIpad: isIpad, isAndroid: isAndroid, isMobile: isMobile, isDesktop: isDesktop };
+
+/***/ }),
+/* 53 */
+/***/ (function(module, exports) {
+
+// Generated by CoffeeScript 1.9.2
+(function() {
+ var root;
+
+ root = typeof exports !== "undefined" && exports !== null ? exports : this;
+
+ root.Lethargy = (function() {
+ function Lethargy(stability, sensitivity, tolerance, delay) {
+ this.stability = stability != null ? Math.abs(stability) : 8;
+ this.sensitivity = sensitivity != null ? 1 + Math.abs(sensitivity) : 100;
+ this.tolerance = tolerance != null ? 1 + Math.abs(tolerance) : 1.1;
+ this.delay = delay != null ? delay : 150;
+ this.lastUpDeltas = (function() {
+ var i, ref, results;
+ results = [];
+ for (i = 1, ref = this.stability * 2; 1 <= ref ? i <= ref : i >= ref; 1 <= ref ? i++ : i--) {
+ results.push(null);
+ }
+ return results;
+ }).call(this);
+ this.lastDownDeltas = (function() {
+ var i, ref, results;
+ results = [];
+ for (i = 1, ref = this.stability * 2; 1 <= ref ? i <= ref : i >= ref; 1 <= ref ? i++ : i--) {
+ results.push(null);
+ }
+ return results;
+ }).call(this);
+ this.deltasTimestamp = (function() {
+ var i, ref, results;
+ results = [];
+ for (i = 1, ref = this.stability * 2; 1 <= ref ? i <= ref : i >= ref; 1 <= ref ? i++ : i--) {
+ results.push(null);
+ }
+ return results;
+ }).call(this);
+ }
+
+ Lethargy.prototype.check = function(e) {
+ var lastDelta;
+ e = e.originalEvent || e;
+ if (e.wheelDelta != null) {
+ lastDelta = e.wheelDelta;
+ } else if (e.deltaY != null) {
+ lastDelta = e.deltaY * -40;
+ } else if ((e.detail != null) || e.detail === 0) {
+ lastDelta = e.detail * -40;
+ }
+ this.deltasTimestamp.push(Date.now());
+ this.deltasTimestamp.shift();
+ if (lastDelta > 0) {
+ this.lastUpDeltas.push(lastDelta);
+ this.lastUpDeltas.shift();
+ return this.isInertia(1);
+ } else {
+ this.lastDownDeltas.push(lastDelta);
+ this.lastDownDeltas.shift();
+ return this.isInertia(-1);
+ }
+ return false;
+ };
+
+ Lethargy.prototype.isInertia = function(direction) {
+ var lastDeltas, lastDeltasNew, lastDeltasOld, newAverage, newSum, oldAverage, oldSum;
+ lastDeltas = direction === -1 ? this.lastDownDeltas : this.lastUpDeltas;
+ if (lastDeltas[0] === null) {
+ return direction;
+ }
+ if (this.deltasTimestamp[(this.stability * 2) - 2] + this.delay > Date.now() && lastDeltas[0] === lastDeltas[(this.stability * 2) - 1]) {
+ return false;
+ }
+ lastDeltasOld = lastDeltas.slice(0, this.stability);
+ lastDeltasNew = lastDeltas.slice(this.stability, this.stability * 2);
+ oldSum = lastDeltasOld.reduce(function(t, s) {
+ return t + s;
+ });
+ newSum = lastDeltasNew.reduce(function(t, s) {
+ return t + s;
+ });
+ oldAverage = oldSum / lastDeltasOld.length;
+ newAverage = newSum / lastDeltasNew.length;
+ if (Math.abs(oldAverage) < Math.abs(newAverage * this.tolerance) && (this.sensitivity < Math.abs(newAverage))) {
+ return direction;
+ } else {
+ return false;
+ }
+ };
+
+ Lethargy.prototype.showLastUpDeltas = function() {
+ return this.lastUpDeltas;
+ };
+
+ Lethargy.prototype.showLastDownDeltas = function() {
+ return this.lastDownDeltas;
+ };
+
+ return Lethargy;
+
+ })();
+
+}).call(this);
+
+
/***/ })
/******/ ]);
//# sourceMappingURL=bundle.js.map \ No newline at end of file