File tree Expand file tree Collapse file tree 7 files changed +47
-12
lines changed
directives/debounced-click
plugins/adaptive-color-scheme Expand file tree Collapse file tree 7 files changed +47
-12
lines changed Original file line number Diff line number Diff line change 22VUE_APP_PACKAGE_JSON = ' '
33
44# TAG must be corresponding with the version tag in package.json, need to modify it when new version releases
5- TAG = 1.1.0
5+ TAG = 1.2.0-beta
Original file line number Diff line number Diff line change 11{
22 "name" : " vuetify-typescript-playground" ,
3- "version" : " 1.1.0 " ,
3+ "version" : " 1.2.0-beta " ,
44 "license" : " Apache-2.0" ,
55 "description" : " Vuetify Typescript Playground" ,
66 "author" : {
Original file line number Diff line number Diff line change 1+ /* eslint-disable no-unused-vars */
2+ import { DirectiveOptions } from 'vue'
3+ import _ from 'lodash'
4+
5+ const debouncedClickDirectiveOptions : DirectiveOptions = {
6+ inserted ( el , directiveBinding ) {
7+ const wait : number = directiveBinding . arg ? + directiveBinding . arg : 1000
8+ el . addEventListener ( 'click' , _ . debounce ( event => {
9+ directiveBinding . value . call ( el , event )
10+ } , wait ) )
11+ }
12+ }
13+
14+ export default debouncedClickDirectiveOptions
Original file line number Diff line number Diff line change 1+ import Vue from 'vue'
2+ import debouncedClickDirectiveOptions from './debounced-click-directive-options'
3+
4+ Vue . directive ( 'debounced-click' , debouncedClickDirectiveOptions )
Original file line number Diff line number Diff line change @@ -6,18 +6,16 @@ import vuetify from './plugins/vuetify'
66import 'roboto-fontface/css/roboto/roboto-fontface.css'
77import '@mdi/font/css/materialdesignicons.css'
88import '@/directives/throttled-click'
9- import { ColorSchemeUtil } from '@/utils/color-scheme-util'
9+ import '@/directives/debounced-click'
10+ import { listenToColorScheme } from '@/plugins/adaptive-color-scheme'
1011
1112Vue . config . productionTip = false
1213
13- const vue = new Vue ( {
14+ const vueInstance = new Vue ( {
1415 router,
1516 store,
1617 vuetify,
1718 render : h => h ( App )
1819} ) . $mount ( '#app' )
1920
20- const media = window . matchMedia ( '(prefers-color-scheme: dark)' )
21- media . addEventListener ( 'change' , ( ) => {
22- vue . $vuetify . theme . dark = ColorSchemeUtil . isDarkMode ( )
23- } )
21+ listenToColorScheme ( vueInstance )
Original file line number Diff line number Diff line change 1+ import { ColorSchemeUtil } from '@/utils/color-scheme-util'
2+ // eslint-disable-next-line no-unused-vars
3+ import Vue from 'vue'
4+
5+ /**
6+ * Listen to color scheme
7+ * @param vueInstance Vue instance
8+ * @author Johnny Miller (鍾俊), e-mail: [email protected] 9+ * @date 12/31/19 7:43 AM
10+ */
11+ export function listenToColorScheme ( vueInstance : Vue ) : void {
12+ const media = window . matchMedia ( '(prefers-color-scheme: dark)' )
13+ media . addEventListener ( 'change' , ( ) => {
14+ vueInstance . $vuetify . theme . dark = ColorSchemeUtil . isDarkMode ( )
15+ } )
16+ }
Original file line number Diff line number Diff line change 22 <div id =" vuetify-demo-container" >
33 <h1 class =" text-center" >This is an about page</h1 >
44 <v-container >
5- <v-carousel cycle height =" 400" hide-delimiter-background show-arrows-on-hover >
5+ <v-carousel cycle height =" 400" hide-delimiter-background show-arrows-on-hover v-ripple >
66 <v-carousel-item v-for =" (slide, i) in slides" :key =" i" >
77 <v-sheet :color =" colors[i]" height =" 100%" >
88 <v-row class =" fill-height" align =" center" justify =" center" >
3939 <v-list-item-avatar tile size =" 80" color =" grey" />
4040 </v-list-item >
4141 <v-card-actions >
42- <v-btn text v-throttled-click:2000 =" handleThrottledClickButton" >Button </v-btn >
43- <v-btn text >Button </v-btn >
42+ <v-btn text v-throttled-click:2000 =" handleThrottledClickButton" >Throttle </v-btn >
43+ <v-btn text v-debounced-click:2000 = " handleDebouncedClickButton " >Debounce </v-btn >
4444 </v-card-actions >
4545 </v-card >
4646 <v-row align =" center" >
@@ -148,7 +148,10 @@ export default Vue.extend({
148148 },
149149 methods: {
150150 handleThrottledClickButton (event : Event ) {
151- console .log (' handleThrottledClickButton' , event )
151+ console .info (' handleThrottledClickButton' , event )
152+ },
153+ handleDebouncedClickButton (event : Event ) {
154+ console .info (' handleDebouncedClickButton' , event )
152155 },
153156 onResize () {
154157 this .windowSize = { x: window .innerWidth , y: window .innerHeight }
You can’t perform that action at this time.
0 commit comments