Merge branch 'master' of gitlab.qima-inc.com:fe/zanui-vue

This commit is contained in:
pangxie1991
2017-04-12 20:04:14 +08:00
16 changed files with 230 additions and 38 deletions
+1
View File
@@ -56,6 +56,7 @@ export default {
title: String,
cancelText: String,
overlay: {
type: Boolean,
default: true
},
closeOnClickOverlay: {
+3 -3
View File
@@ -10,7 +10,7 @@ let dialogQueue = [];
const defaultCallback = action => {
if (currentDialog) {
let callback = currentDialog.callback;
const callback = currentDialog.callback;
if (typeof callback === 'function') {
callback(action);
@@ -40,9 +40,9 @@ const showNextDialog = () => {
if (!instance.value && dialogQueue.length > 0) {
currentDialog = dialogQueue.shift();
let options = currentDialog.options;
const options = currentDialog.options;
for (let prop in options) {
for (const prop in options) {
if (options.hasOwnProperty(prop)) {
instance[prop] = options[prop];
}
+4 -1
View File
@@ -7,7 +7,10 @@
name: 'zan-icon',
props: {
name: String
name: {
type: String,
required: true
}
},
methods: {
@@ -1,6 +1,5 @@
import Vue from 'vue';
import ImagePreview from './image-preview.vue';
import merge from 'src/utils/merge';
let instance;
+2 -3
View File
@@ -24,7 +24,6 @@ Input.prototype = Object.create(new EventEmitter());
extend(Input.prototype, {
bind: function(host) {
bindEvents(host, 'touchstart mousedown', this.onTouchStart);
if (this.options.listenMoving) {
bindEvents(window, 'touchmove mousemove', this.onTouchMove);
@@ -74,11 +73,11 @@ extend(Input.prototype, {
this.orgDirection = Math.abs(distX) > Math.abs(distY);
}
this.emit('move', {x: distX, y: distY}, isEnd, e, {orgDirection: this.orgDirection});
this.emit('move', { x: distX, y: distY }, isEnd, e, { orgDirection: this.orgDirection });
},
pointerEventToXY: function(e) {
var out = {x: 0, y: 0};
var out = { x: 0, y: 0 };
var type = e.type;
if (e.originalEvent) {
e = e.originalEvent;
+8 -8
View File
@@ -1,10 +1,10 @@
import { EventEmitter, extend } from './utils'
import { EventEmitter, extend } from './utils';
const setElementsStyles = (elems, styles) => {
Array.prototype.forEach.call(elems, item => {
extend(item.style, styles)
})
}
extend(item.style, styles);
});
};
function Scroll(wrapElem, options) {
EventEmitter.apply(this, arguments);
@@ -33,14 +33,14 @@ extend(Scroll.prototype, {
},
update: function() {
const oldPages = this.pages
const oldPages = this.pages;
this.pages = this.wrapElem.querySelectorAll('.zan-swipe-item');
if (oldPages && oldPages.length === this.pages.length) {
const isSame = Array.prototype.every.call(this.pages, (elem, index) => {
return this.pages[index] === oldPages[index]
})
return this.pages[index] === oldPages[index];
});
if (isSame) {
return
return;
}
}
var defaultStyle = {
+3 -5
View File
@@ -1,4 +1,4 @@
import { requestAnimationFrame, cancelAnimationFrame, EventEmitter, extend } from './utils'
import { requestAnimationFrame, cancelAnimationFrame, EventEmitter, extend } from './utils';
function SpringDummy(scroll, input, options) {
var wrapElem = scroll.wrapElem;
@@ -31,7 +31,6 @@ function SpringDummy(scroll, input, options) {
}).on('bounceStart', function() {
self.input.deaf();
});
}
SpringDummy.prototype = Object.create(new EventEmitter());
@@ -85,7 +84,6 @@ extend(SpringDummy.prototype, {
addition = w * (tempOffsetPage - offsetPage + this.scroll.pages.length - 1);
}
}
}
this.initTween(addition - dist, 150, 'bounce');
@@ -105,12 +103,12 @@ extend(SpringDummy.prototype, {
function round() {
elapse = new Date() - startTime;
if (elapse > duration) {
self.emit(eventName, {x: dist}, true);
self.emit(eventName, { x: dist }, true);
self.emit(eventName + 'End');
return;
}
self.emit(eventName, {x: dist / duration * elapse}, false);
self.emit(eventName, { x: dist / duration * elapse }, false);
self.tweenRid = requestAnimationFrame(round);
}
round();
+8 -8
View File
@@ -18,11 +18,11 @@ EventEmitter.prototype = {
if (arr) {
arr.forEach(function(cb) {
cb.apply(self, argus);
})
});
}
},
removeListener: function(name, fn) {
if (this.__events[name] == undefined) {
if (!this.__events[name]) {
return;
}
let index;
@@ -50,14 +50,14 @@ const cancelAnimationFrame = window.cancelAnimationFrame || window.mozCancelAnim
};
const bindEvents = (elem, eventNames, fn) => {
eventNames = eventNames.split(/\s+/)
eventNames.forEach(eventName => elem.addEventListener(eventName, fn))
}
eventNames = eventNames.split(/\s+/);
eventNames.forEach(eventName => elem.addEventListener(eventName, fn));
};
const removeEvents = (elem, eventNames, fn) => {
eventNames = eventNames.split(/\s+/)
eventNames.forEach(eventName => elem.removeEventListener(eventName, fn))
}
eventNames = eventNames.split(/\s+/);
eventNames.forEach(eventName => elem.removeEventListener(eventName, fn));
};
export {
extend,
+2 -3
View File
@@ -13,7 +13,6 @@ const getInstance = () => {
return instance;
};
const removeDom = event => {
if (event.target.parentNode) {
event.target.parentNode.removeChild(event.target);
@@ -23,7 +22,7 @@ const removeDom = event => {
var Toast = (options = {}) => {
const duration = options.duration || 3000;
let instance = getInstance();
const instance = getInstance();
instance.closed = false;
clearTimeout(instance.timer);
instance.type = options.type ? options.type : 'text';
@@ -71,6 +70,6 @@ Toast.fail = (options) => {
Toast.clear = () => {
if (instance) instance.clear();
}
};
export default Toast;