From 1b8f8f6b516f37c642b4928f5297dd8932c0dd26 Mon Sep 17 00:00:00 2001 From: funanamy Date: Wed, 8 Nov 2017 14:26:31 +0800 Subject: [PATCH 1/2] enhance scroll demo: add options --- .../components/input-option/input-option.vue | 56 +++ .../select-option/select-option.vue | 63 +++ .../switch-option/switch-option.vue | 83 ++++ example/data/ease.js | 23 ++ example/pages/scroll.vue | 391 ++++++++++++++---- src/components/scroll/scroll.vue | 7 +- 6 files changed, 551 insertions(+), 72 deletions(-) create mode 100644 example/components/input-option/input-option.vue create mode 100644 example/components/select-option/select-option.vue create mode 100644 example/components/switch-option/switch-option.vue create mode 100755 example/data/ease.js diff --git a/example/components/input-option/input-option.vue b/example/components/input-option/input-option.vue new file mode 100644 index 000000000..e6eaf3f36 --- /dev/null +++ b/example/components/input-option/input-option.vue @@ -0,0 +1,56 @@ + + + + + diff --git a/example/components/select-option/select-option.vue b/example/components/select-option/select-option.vue new file mode 100644 index 000000000..de3b2cac4 --- /dev/null +++ b/example/components/select-option/select-option.vue @@ -0,0 +1,63 @@ + + + + + diff --git a/example/components/switch-option/switch-option.vue b/example/components/switch-option/switch-option.vue new file mode 100644 index 000000000..6a9e562a0 --- /dev/null +++ b/example/components/switch-option/switch-option.vue @@ -0,0 +1,83 @@ + + + + + diff --git a/example/data/ease.js b/example/data/ease.js new file mode 100755 index 000000000..006689387 --- /dev/null +++ b/example/data/ease.js @@ -0,0 +1,23 @@ +export const ease = { + // easeOutQuint + swipe: { + style: 'cubic-bezier(0.23, 1, 0.32, 1)', + fn: function (t) { + return 1 + (--t * t * t * t * t) + } + }, + // easeOutQuard + swipeBounce: { + style: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)', + fn: function (t) { + return t * (2 - t) + } + }, + // easeOutQuart + bounce: { + style: 'cubic-bezier(0.165, 0.84, 0.44, 1)', + fn: function (t) { + return 1 - (--t * t * t * t) + } + } +} diff --git a/example/pages/scroll.vue b/example/pages/scroll.vue index b34e7e363..d42d59ff3 100644 --- a/example/pages/scroll.vue +++ b/example/pages/scroll.vue @@ -1,40 +1,107 @@ diff --git a/src/components/scroll/scroll.vue b/src/components/scroll/scroll.vue index 02e44bc51..0b3a8838e 100644 --- a/src/components/scroll/scroll.vue +++ b/src/components/scroll/scroll.vue @@ -128,11 +128,11 @@ }, mounted() { setTimeout(() => { - this._initScroll() + this.initScroll() }, 20) }, methods: { - _initScroll() { + initScroll() { if (!this.$refs.wrapper) { return } @@ -181,6 +181,9 @@ refresh() { this.scroll && this.scroll.refresh() }, + destroy() { + this.scroll.destroy() + }, scrollTo() { this.scroll && this.scroll.scrollTo.apply(this.scroll, arguments) }, From 032e81540c9202bac167df94753e1dda848ebc25 Mon Sep 17 00:00:00 2001 From: funanamy Date: Wed, 8 Nov 2017 14:52:25 +0800 Subject: [PATCH 2/2] fix scroll demo UI bug --- example/components/input-option/input-option.vue | 4 ++-- example/components/select-option/select-option.vue | 5 +++-- example/pages/scroll.vue | 7 ------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/example/components/input-option/input-option.vue b/example/components/input-option/input-option.vue index e6eaf3f36..a9374d34f 100644 --- a/example/components/input-option/input-option.vue +++ b/example/components/input-option/input-option.vue @@ -39,8 +39,8 @@ align-items stretch padding-left: 15px .name - flex: 0 1 auto - width: 10rem + flex: 0 0 auto + width: 8rem display inline-flex align-items center input diff --git a/example/components/select-option/select-option.vue b/example/components/select-option/select-option.vue index de3b2cac4..fb700dd7d 100644 --- a/example/components/select-option/select-option.vue +++ b/example/components/select-option/select-option.vue @@ -45,12 +45,13 @@ align-items stretch padding-left: 15px .name - flex: 0 1 auto - width: 10rem + flex: 0 0 auto + width: 8rem display inline-flex align-items center select flex: 1 1 auto + padding-left: 0.8rem background-color: $color-white border: none border-left: 1px solid rgba(0, 0, 0, .1) diff --git a/example/pages/scroll.vue b/example/pages/scroll.vue index d42d59ff3..dae8690b3 100644 --- a/example/pages/scroll.vue +++ b/example/pages/scroll.vue @@ -293,9 +293,6 @@ .wrapper background: $color-white .scroll-wrapper - display: flex - justify-content: space-between - flex-wrap: wrap .title font-size: 1.5rem font-weight: 500 @@ -304,10 +301,6 @@ border-bottom: 1px solid rgba(0, 0, 0, .1) margin-bottom: 1rem .options - @media screen and (min-width: 42rem) - flex: 0 1 25% - @media screen and (max-width: 42rem) - flex: 0 1 100% margin-bottom: 1rem .option-list