@insaic/neon
Version:
A Mobile UI Components built on Vue
497 lines (426 loc) • 14.4 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;
/******/
/******/ // 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 = 293);
/******/ })
/************************************************************************/
/******/ ({
/***/ 0:
/***/ (function(module, exports) {
/* globals __VUE_SSR_CONTEXT__ */
// IMPORTANT: Do NOT use ES2015 features in this file.
// 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,
functionalTemplate,
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
options._compiled = true
}
// functional template
if (functionalTemplate) {
options.functional = true
}
// 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 {
// for template-only hot-reload because in that case the render fn doesn't
// go through the normalizer
options._injectStyles = hook
// 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
}
}
/***/ }),
/***/ 141:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/* harmony default export */ __webpack_exports__["a"] = ({
name: 'sq-swiper',
props: {
autoplay: {
type: [String, Number],
default: 3000
},
duration: {
type: [String, Number],
default: 300
},
showIndicators: {
type: Boolean,
default: true
},
touchable: {
type: Boolean,
default: true
}
},
computed: {
wrapStyles: function wrapStyles() {
return {
'transform': 'translateX(' + this.translateX + 'px)',
'transition': 'transform ' + this.duration + 'ms',
'width': this.offsetWidth * this.childItems.length + 'px'
};
},
count: function count() {
return this.childItems.length;
}
},
data: function data() {
return {
currentIndex: 0,
offsetWidth: 0,
translateX: 0,
firstWrap: 0,
lastWrap: 0,
childItems: [],
timer: null,
startPosition: 0,
savePosition: 0,
moveValue: 0
};
},
methods: {
onTouchStart: function onTouchStart(event) {
if (!this.touchable) return;
this.clear();
if (this.currentIndex === this.count) {
this.currentIndex = 0;
this.firstWrap = 0;
this.duration = 0;
this.translateX = 0;
}
if (this.currentIndex === this.count - 1 && this.translateX === this.offsetWidth) {
this.duration = 0;
this.lastWrap = 0;
this.translateX = -this.offsetWidth * this.currentIndex;
}
this.startPosition = event.changedTouches[0].pageX;
this.savePosition = this.translateX;
},
onTouchMove: function onTouchMove(event) {
if (!this.touchable) return;
this.moveValue = event.changedTouches[0].pageX - this.startPosition;
this.translateX = this.savePosition + this.moveValue;
var count = this.count;
if (this.currentIndex === count - 1) {
this.firstWrap = this.offsetWidth * count;
}
// first to last, move last position
if (this.moveValue > 0 && this.currentIndex === 0) {
this.lastWrap = this.offsetWidth * count * -1;
}
event.preventDefault();
event.stopPropagation();
},
onTouchEnd: function onTouchEnd(event) {
var _this = this;
if (!this.touchable) return;
if (Math.abs(this.moveValue) > 50) {
var direction = 1;
if (this.moveValue > 0) {
// 2 -> 1 左移
direction = -1;
}
var count = this.count;
if (this.currentIndex === count - 1) {
this.firstWrap = this.offsetWidth * count;
}
// 重置this.firstWrap
if (this.currentIndex === 0) {
this.firstWrap = 0;
}
if (this.currentIndex === count) {
this.currentIndex = 0;
this.firstWrap = 0;
this.duration = 0;
this.translateX = 0;
setTimeout(function () {
_this.duration = 300;
direction === 1 ? ++_this.currentIndex : --_this.currentIndex;
if (_this.currentIndex < 0) {
_this.currentIndex = count - 1;
}
_this.translateX = -_this.offsetWidth * _this.currentIndex;
}, 100);
return;
}
if (this.duration === 0) {
this.duration = 300;
}
direction === 1 ? ++this.currentIndex : --this.currentIndex;
if (this.currentIndex < 0) {
this.currentIndex = count - 1;
}
if (this.currentIndex === count - 1 && direction !== 1) {
this.translateX = this.offsetWidth;
} else {
this.translateX = -this.offsetWidth * this.currentIndex;
}
} else {
if (this.duration === 0) {
this.duration = 300;
}
this.translateX = this.savePosition;
}
this.autoPlay();
},
clear: function clear() {
clearInterval(this.timer);
},
autoPlay: function autoPlay() {
var _this2 = this;
var autoplay = this.autoplay,
count = this.count;
this.clear();
this.timer = setInterval(function () {
if (_this2.currentIndex === count - 1) {
_this2.firstWrap = _this2.offsetWidth * count;
}
if (_this2.currentIndex === count - 1 && _this2.translateX === _this2.offsetWidth) {
_this2.duration = 0;
_this2.lastWrap = 0;
_this2.translateX = -_this2.offsetWidth * _this2.currentIndex;
}
if (_this2.currentIndex === count) {
_this2.currentIndex = 0;
_this2.firstWrap = 0;
_this2.duration = 0;
_this2.translateX = 0;
setTimeout(function () {
_this2.duration = 300;
_this2.translateX = -_this2.offsetWidth * ++_this2.currentIndex;
}, 100);
return;
}
if (_this2.duration === 0) {
_this2.duration = 300;
}
_this2.translateX = -_this2.offsetWidth * ++_this2.currentIndex;
}, autoplay);
},
offsetWidthResize: function offsetWidthResize() {
this.offsetWidth = this.$el.offsetWidth;
}
},
mounted: function mounted() {
this.offsetWidth = this.$el.offsetWidth;
this.autoPlay();
window.addEventListener('resize', this.offsetWidthResize, false);
},
destroyed: function destroyed() {
this.clear();
window.removeEventListener('resize', this.offsetWidthResize);
}
});
/***/ }),
/***/ 293:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_index_vue__ = __webpack_require__(294);
__WEBPACK_IMPORTED_MODULE_0__src_index_vue__["a" /* default */].install = function (Vue) {
Vue.component(__WEBPACK_IMPORTED_MODULE_0__src_index_vue__["a" /* default */].name, __WEBPACK_IMPORTED_MODULE_0__src_index_vue__["a" /* default */]);
};
/* harmony default export */ __webpack_exports__["default"] = (__WEBPACK_IMPORTED_MODULE_0__src_index_vue__["a" /* default */]);
/***/ }),
/***/ 294:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_index_vue__ = __webpack_require__(141);
/* unused harmony namespace reexport */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_31e2f766_hasScoped_false_transformToRequire_video_src_poster_source_src_img_src_image_xlink_href_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_index_vue__ = __webpack_require__(296);
function injectStyle (ssrContext) {
__webpack_require__(295)
}
var normalizeComponent = __webpack_require__(0)
/* script */
/* template */
/* template functional */
var __vue_template_functional__ = false
/* styles */
var __vue_styles__ = injectStyle
/* scopeId */
var __vue_scopeId__ = null
/* moduleIdentifier (server only) */
var __vue_module_identifier__ = null
var Component = normalizeComponent(
__WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_index_vue__["a" /* default */],
__WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_31e2f766_hasScoped_false_transformToRequire_video_src_poster_source_src_img_src_image_xlink_href_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_index_vue__["a" /* default */],
__vue_template_functional__,
__vue_styles__,
__vue_scopeId__,
__vue_module_identifier__
)
/* harmony default export */ __webpack_exports__["a"] = (Component.exports);
/***/ }),
/***/ 295:
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/***/ 296:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"sq-swiper"},[_c('div',{staticClass:"sq-swiper-wrap",style:(_vm.wrapStyles),on:{"touchstart":_vm.onTouchStart,"touchmove":_vm.onTouchMove,"touchend":_vm.onTouchEnd,"touchcancel":_vm.onTouchEnd}},[_vm._t("default")],2),_vm._v(" "),(_vm.showIndicators)?_c('div',{staticClass:"sq-swiper-point-wrap"},_vm._l((_vm.childItems),function(item,index){return _c('div',{key:index,staticClass:"sq-swiper-point-item",class:{
'sq-swiper-point-active': index === _vm.currentIndex || (index === 0 && _vm.currentIndex === _vm.count)
}})})):_vm._e()])}
var staticRenderFns = []
var esExports = { render: render, staticRenderFns: staticRenderFns }
/* harmony default export */ __webpack_exports__["a"] = (esExports);
/***/ })
/******/ });