vuescroll
Version:
A powerful, customizable, multi-mode scrollbar plugin based on Vue.js
88 lines (84 loc) • 2.35 kB
JavaScript
/**
* The slide mode config
*/
import { error } from 'shared/util';
export const config = {
// vuescroll
vuescroll: {
// position or transform
renderMethod: 'transform',
// pullRefresh or pushLoad is only for the slide mode...
pullRefresh: {
enable: false,
tips: {
deactive: 'Pull to Refresh',
active: 'Release to Refresh',
start: 'Refreshing...',
beforeDeactive: 'Refresh Successfully!'
}
},
pushLoad: {
enable: false,
tips: {
deactive: 'Push to Load',
active: 'Release to Load',
start: 'Loading...',
beforeDeactive: 'Load Successfully!'
},
auto: false,
autoLoadDistance: 0
},
paging: false,
zooming: true,
snapping: {
enable: false,
width: 100,
height: 100
},
/* some scroller options */
scroller: {
/** Enable bouncing (content can be slowly moved outside and jumps back after releasing) */
bouncing: {
top: 100,
bottom: 100,
left: 100,
right: 100
},
/** Minimum zoom level */
minZoom: 0.5,
/** Maximum zoom level */
maxZoom: 3,
/** Multiply or decrease scrolling speed **/
speedMultiplier: 1,
/** This configures the amount of change applied to deceleration when reaching boundaries **/
penetrationDeceleration: 0.03,
/** This configures the amount of change applied to acceleration when reaching boundaries **/
penetrationAcceleration: 0.08,
/** Whether call e.preventDefault event when sliding the content or not */
preventDefault: false,
/** Whether call preventDefault when (mouse/touch)move*/
preventDefaultOnMove: true,
disable: false
}
}
};
/**
* validate the options
* @export
* @param {any} ops
*/
export function configValidator(ops) {
let renderError = false;
const { vuescroll } = ops;
// validate pushLoad, pullReresh, snapping
if (
vuescroll.paging == vuescroll.snapping.enable &&
vuescroll.paging &&
(vuescroll.pullRefresh || vuescroll.pushLoad)
) {
error(
'paging, snapping, (pullRefresh with pushLoad) can only one of them to be true.'
);
}
return renderError;
}