mint-ui
Version:
Mobile UI elements for vue.js
454 lines (388 loc) • 10.6 kB
JavaScript
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 219);
/******/ })
/************************************************************************/
/******/ ({
/***/ 0:
/***/ function(module, exports) {
/* globals __VUE_SSR_CONTEXT__ */
// this module is a runtime utility for cleaner component module output and will
// be included in the final webpack user bundle
module.exports = function normalizeComponent (
rawScriptExports,
compiledTemplate,
injectStyles,
scopeId,
moduleIdentifier /* server only */
) {
var esModule
var scriptExports = rawScriptExports = rawScriptExports || {}
// ES6 modules interop
var type = typeof rawScriptExports.default
if (type === 'object' || type === 'function') {
esModule = rawScriptExports
scriptExports = rawScriptExports.default
}
// Vue.extend constructor export interop
var options = typeof scriptExports === 'function'
? scriptExports.options
: scriptExports
// render functions
if (compiledTemplate) {
options.render = compiledTemplate.render
options.staticRenderFns = compiledTemplate.staticRenderFns
}
// scopedId
if (scopeId) {
options._scopeId = scopeId
}
var hook
if (moduleIdentifier) { // server build
hook = function (context) {
// 2.3 injection
context =
context || // cached call
(this.$vnode && this.$vnode.ssrContext) || // stateful
(this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
// 2.2 with runInNewContext: true
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
context = __VUE_SSR_CONTEXT__
}
// inject component styles
if (injectStyles) {
injectStyles.call(this, context)
}
// register component module identifier for async chunk inferrence
if (context && context._registeredComponents) {
context._registeredComponents.add(moduleIdentifier)
}
}
// used by ssr in case component is cached and beforeCreate
// never gets called
options._ssrRegister = hook
} else if (injectStyles) {
hook = injectStyles
}
if (hook) {
var functional = options.functional
var existing = functional
? options.render
: options.beforeCreate
if (!functional) {
// inject component registration as beforeCreate hook
options.beforeCreate = existing
? [].concat(existing, hook)
: [hook]
} else {
// register for functioal component in vue file
options.render = function renderWithStyleInjection (h, context) {
hook.call(context)
return existing(h, context)
}
}
}
return {
esModule: esModule,
exports: scriptExports,
options: options
}
}
/***/ },
/***/ 139:
/***/ function(module, exports, __webpack_require__) {
function injectStyle (ssrContext) {
__webpack_require__(97)
}
var Component = __webpack_require__(0)(
/* script */
__webpack_require__(61),
/* template */
__webpack_require__(166),
/* styles */
injectStyle,
/* scopeId */
null,
/* moduleIdentifier (server only) */
null
)
module.exports = Component.exports
/***/ },
/***/ 166:
/***/ function(module, exports) {
module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
return _c('div', {
staticClass: "mint-indexlist"
}, [_c('ul', {
ref: "content",
staticClass: "mint-indexlist-content",
style: ({
'height': _vm.currentHeight + 'px',
'margin-right': _vm.navWidth + 'px'
})
}, [_vm._t("default")], 2), _vm._v(" "), _c('div', {
ref: "nav",
staticClass: "mint-indexlist-nav",
on: {
"touchstart": _vm.handleTouchStart
}
}, [_c('ul', {
staticClass: "mint-indexlist-navlist"
}, _vm._l((_vm.sections), function(section) {
return _c('li', {
staticClass: "mint-indexlist-navitem"
}, [_vm._v(_vm._s(section.index))])
}))]), _vm._v(" "), (_vm.showIndicator) ? _c('div', {
directives: [{
name: "show",
rawName: "v-show",
value: (_vm.moving),
expression: "moving"
}],
staticClass: "mint-indexlist-indicator"
}, [_vm._v(_vm._s(_vm.currentIndicator))]) : _vm._e()])
},staticRenderFns: []}
/***/ },
/***/ 219:
/***/ function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(27);
/***/ },
/***/ 27:
/***/ function(module, exports, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_index_list_vue__ = __webpack_require__(139);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_index_list_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__src_index_list_vue__);
Object.defineProperty(exports, "__esModule", { value: true });
/* harmony reexport (default from non-hamory) */ __webpack_require__.d(exports, "default", function() { return __WEBPACK_IMPORTED_MODULE_0__src_index_list_vue___default.a; });
/***/ },
/***/ 61:
/***/ function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/* harmony default export */ exports["default"] = {
name: 'mt-index-list',
props: {
height: Number,
showIndicator: {
type: Boolean,
default: true
}
},
data: function data() {
return {
sections: [],
navWidth: 0,
indicatorTime: null,
moving: false,
firstSection: null,
currentIndicator: '',
currentHeight: this.height,
navOffsetX: 0
};
},
watch: {
sections: function sections() {
this.init();
},
height: function height(val) {
if (val) {
this.currentHeight = val;
}
}
},
methods: {
init: function init() {
var this$1 = this;
this.$nextTick(function () {
this$1.navWidth = this$1.$refs.nav.clientWidth;
});
var listItems = this.$refs.content.getElementsByTagName('li');
if (listItems.length > 0) {
this.firstSection = listItems[0];
}
},
handleTouchStart: function handleTouchStart(e) {
if (e.target.tagName !== 'LI') {
return;
}
this.navOffsetX = e.changedTouches[0].clientX;
this.scrollList(e.changedTouches[0].clientY);
if (this.indicatorTime) {
clearTimeout(this.indicatorTime);
}
this.moving = true;
window.addEventListener('touchmove', this.handleTouchMove);
window.addEventListener('touchend', this.handleTouchEnd);
},
handleTouchMove: function handleTouchMove(e) {
e.preventDefault();
this.scrollList(e.changedTouches[0].clientY);
},
handleTouchEnd: function handleTouchEnd() {
var this$1 = this;
this.indicatorTime = setTimeout(function () {
this$1.moving = false;
this$1.currentIndicator = '';
}, 500);
window.removeEventListener('touchmove', this.handleTouchMove);
window.removeEventListener('touchend', this.handleTouchEnd);
},
scrollList: function scrollList(y) {
var currentItem = document.elementFromPoint(this.navOffsetX, y);
if (!currentItem || !currentItem.classList.contains('mint-indexlist-navitem')) {
return;
}
this.currentIndicator = currentItem.innerText;
var targets = this.sections.filter(function (section) { return section.index === currentItem.innerText; });
var targetDOM;
if (targets.length > 0) {
targetDOM = targets[0].$el;
this.$refs.content.scrollTop = targetDOM.getBoundingClientRect().top - this.firstSection.getBoundingClientRect().top;
}
}
},
mounted: function mounted() {
var this$1 = this;
if (!this.currentHeight) {
window.scrollTo(0, 0);
requestAnimationFrame(function (){
this$1.currentHeight = document.documentElement.clientHeight - this$1.$refs.content.getBoundingClientRect().top;
});
}
this.init();
}
};
/***/ },
/***/ 97:
/***/ function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }
/******/ });