material 0.7.0 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/README.md +1 -5
  2. package/dist/demo-bundle.js +2281 -2
  3. package/dist/demo-bundle.js.map +7 -1
  4. package/dist/demo.js +13 -13
  5. package/esbuild.js +22 -0
  6. package/esbuild.watch.js +25 -0
  7. package/form.js +27 -0
  8. package/index.js +59 -58
  9. package/list.js +35 -0
  10. package/package.json +8 -17
  11. package/src/appbar.js +7 -204
  12. package/src/badge.js +27 -0
  13. package/src/button.js +127 -177
  14. package/src/calendar.js +53 -55
  15. package/src/card.js +1 -3
  16. package/src/checkbox.js +5 -55
  17. package/src/component.js +0 -2
  18. package/src/container.js +0 -2
  19. package/src/datehour.js +38 -0
  20. package/src/dialog.js +104 -151
  21. package/src/divider.js +1 -3
  22. package/src/drawer.js +1 -19
  23. package/src/element/attribute.js +7 -10
  24. package/src/element/build.js +6 -7
  25. package/src/element/create.js +3 -6
  26. package/src/element/event.js +2 -2
  27. package/src/element/insert.js +6 -17
  28. package/src/element/observer.js +22 -0
  29. package/src/element/offset.js +2 -2
  30. package/src/element/style.js +12 -12
  31. package/src/element.js +2 -2
  32. package/src/field/email.js +9 -44
  33. package/src/field/image.js +17 -51
  34. package/src/{control/file.js → file.js} +15 -45
  35. package/src/form/build.js +7 -7
  36. package/src/form/controller.js +8 -8
  37. package/src/form/create.js +1 -1
  38. package/src/form/data.js +9 -9
  39. package/src/form/delete.js +1 -1
  40. package/src/form/render.js +9 -9
  41. package/src/form/set.js +1 -1
  42. package/src/form/submit.js +6 -6
  43. package/src/form/update.js +3 -3
  44. package/src/form/verify.js +6 -6
  45. package/src/form.js +9 -11
  46. package/src/icon.js +4 -6
  47. package/src/image.js +39 -106
  48. package/src/item.js +1 -3
  49. package/src/layout.js +14 -14
  50. package/src/{control/link.js → link.js} +13 -32
  51. package/src/list/build.js +10 -10
  52. package/src/list/click.js +3 -3
  53. package/src/list/collection.js +1 -1
  54. package/src/list/filter.js +11 -11
  55. package/src/list/image.js +3 -3
  56. package/src/list/render.js +15 -15
  57. package/src/list/request.js +8 -8
  58. package/src/list/search.js +12 -12
  59. package/src/list/select.js +18 -18
  60. package/src/list/status.js +1 -1
  61. package/src/list/update.js +6 -6
  62. package/src/list/virtual.js +20 -20
  63. package/src/list/virtual.new.js +5 -5
  64. package/src/list.js +29 -217
  65. package/src/loading.js +73 -0
  66. package/src/map/build.js +2 -2
  67. package/src/map/countries.js +8 -8
  68. package/src/map/display.js +13 -13
  69. package/src/map/focus.js +7 -7
  70. package/src/map/select.js +2 -2
  71. package/src/map/set.js +3 -3
  72. package/src/map/viewport.js +11 -11
  73. package/src/menu.js +59 -115
  74. package/src/mixin/control.js +3 -3
  75. package/src/mixin/controller.js +5 -5
  76. package/src/mixin/create.js +1 -1
  77. package/src/mixin/display.js +1 -2
  78. package/src/mixin/events.js +4 -16
  79. package/src/mixin/focus.js +1 -1
  80. package/src/mixin/icon.js +2 -2
  81. package/src/mixin/init.js +2 -2
  82. package/src/mixin/insert.js +7 -29
  83. package/src/mixin/label.js +2 -2
  84. package/src/mixin/settings.js +5 -5
  85. package/src/module/attach.js +35 -49
  86. package/src/{control/module → module}/attributes.js +4 -4
  87. package/src/module/build.js +12 -12
  88. package/src/module/classify.js +4 -4
  89. package/src/module/controller.js +5 -32
  90. package/src/module/css.js +12 -84
  91. package/src/module/dataset.js +1 -1
  92. package/src/module/dom.js +8 -3
  93. package/src/module/dot.js +4 -4
  94. package/src/module/emitter.js +1 -1
  95. package/src/module/event.js +2 -2
  96. package/src/module/events.js +29 -35
  97. package/src/module/extract.js +10 -10
  98. package/src/module/last.js +18 -0
  99. package/src/module/mediator.js +1 -13
  100. package/src/module/object.js +4 -4
  101. package/src/module/observer.js +43 -16
  102. package/src/module/remove.js +10 -10
  103. package/src/module/ripple.js +19 -24
  104. package/src/module/scrollbar.js +10 -14
  105. package/src/module/smoothscroll.js +5 -9
  106. package/src/module/utils.js +14 -23
  107. package/src/module/viewport.js +5 -5
  108. package/src/navigation.js +19 -0
  109. package/src/progress.js +1 -11
  110. package/src/search.js +66 -0
  111. package/src/select.js +58 -273
  112. package/src/{control/selecter.js → selecter.js} +42 -42
  113. package/src/selector.js +3 -3
  114. package/src/skin/material/component/navigation.sass +9 -0
  115. package/src/skin/material/control/button.sass +10 -0
  116. package/src/slider.js +1 -3
  117. package/src/snackbar.js +72 -50
  118. package/src/switch.js +111 -103
  119. package/src/{control/switcher.js → switcher.js} +28 -31
  120. package/src/tabs.js +4 -5
  121. package/src/tabview.js +26 -46
  122. package/src/text.js +25 -74
  123. package/src/textfield.js +97 -234
  124. package/src/toolbar.js +12 -12
  125. package/src/tooltip.js +7 -7
  126. package/src/tree.js +10 -66
  127. package/src/view/build.js +2 -2
  128. package/src/view/dataset.js +1 -1
  129. package/src/view.js +9 -74
  130. package/rollup.config.js +0 -34
  131. package/src/banner.js +0 -231
  132. package/src/control/button.js +0 -239
  133. package/src/control/button.new.js +0 -190
  134. package/src/control/datehour.js +0 -65
  135. package/src/control/dialog.js +0 -175
  136. package/src/control/image.js +0 -92
  137. package/src/control/list.js +0 -67
  138. package/src/control/loading.js +0 -128
  139. package/src/control/menu.js +0 -85
  140. package/src/control/module/addclass.js +0 -16
  141. package/src/control/search.js +0 -98
  142. package/src/control/select.js +0 -130
  143. package/src/control/snackbar.js +0 -91
  144. package/src/control/switch.js +0 -272
  145. package/src/control/text.js +0 -70
  146. package/src/control/textfield.js +0 -177
  147. package/src/element/ripple.js +0 -90
  148. package/src/tabs/setup.js +0 -0
@@ -23,7 +23,7 @@ export default {
23
23
  // console.log('renderItem', info)
24
24
  info = info || {}
25
25
 
26
- var container = this.ui.body
26
+ const container = this.ui.body
27
27
 
28
28
  if (context === 'create') {
29
29
  container.scrolltop = 0
@@ -33,7 +33,7 @@ export default {
33
33
  // container = this.ui['search-list']
34
34
  // }
35
35
 
36
- var element = new Element({
36
+ const element = new Element({
37
37
  tag: 'li',
38
38
  class: 'item'
39
39
  })
@@ -47,10 +47,10 @@ export default {
47
47
  element.dataset.id = info[this.dataId]
48
48
  element.dataset.info = this.options.info
49
49
 
50
- var layout = null
50
+ let layout = null
51
51
 
52
52
  if (this.options.itemSwitch) {
53
- var item = info[this.options.itemSwitch]
53
+ const item = info[this.options.itemSwitch]
54
54
 
55
55
  if (this.options.layout.item[item]) {
56
56
  layout = new Layout(this.options.layout.item[item], element)
@@ -58,7 +58,7 @@ export default {
58
58
  layout = new Layout(this.options.layout.item.base, element)
59
59
  }
60
60
  } else {
61
- var itemName = this.options.itemName || 'item'
61
+ const itemName = this.options.itemName || 'item'
62
62
  layout = new Layout(this.options.layout[itemName], element)
63
63
  }
64
64
 
@@ -91,11 +91,11 @@ export default {
91
91
  */
92
92
  renderInfo (layout, object) {
93
93
  // console.log('renderInfo', object)
94
- var info = dot(object)
94
+ const info = dot(object)
95
95
 
96
- var f = this.extractInfo(layout.component)
96
+ const f = this.extractInfo(layout.component)
97
97
 
98
- for (var field in f) {
98
+ for (const field in f) {
99
99
  if (f.hasOwnProperty(field)) {
100
100
  if (f[field] && f[field].set) {
101
101
  f[field].set(this.objectValueByDotKey(object, field))
@@ -108,11 +108,11 @@ export default {
108
108
  },
109
109
 
110
110
  objectValueByDotKey (object, dotkey) {
111
- var keys = dotkey.split(/\./)
111
+ const keys = dotkey.split(/\./)
112
112
 
113
- var value = Object.assign({}, object)
113
+ let value = Object.assign({}, object)
114
114
 
115
- for (var i = 0; i < keys.length; i++) {
115
+ for (let i = 0; i < keys.length; i++) {
116
116
  if (value !== undefined) {
117
117
  value = value[keys[i]]
118
118
  }
@@ -124,14 +124,14 @@ export default {
124
124
  extractInfo (object) {
125
125
  // console.log('extractField', object)
126
126
 
127
- var field = {}
127
+ const field = {}
128
128
 
129
- for (var property in object) {
129
+ for (const property in object) {
130
130
  if (object.hasOwnProperty(property)) {
131
- var infos = property.split(/\./)
131
+ const infos = property.split(/\./)
132
132
 
133
133
  if (infos[0] === 'info' && infos[1] !== undefined) {
134
- var name = property.substr(5, property.length)
134
+ const name = property.substr(5, property.length)
135
135
  // console.log('field', name, property)
136
136
 
137
137
  field[name] = object[property]
@@ -16,7 +16,7 @@ export default {
16
16
  }
17
17
 
18
18
  this.data = this.data || []
19
- var signal = null
19
+ let signal = null
20
20
 
21
21
  if (this.abortController) {
22
22
  // console.log('abort')
@@ -37,7 +37,7 @@ export default {
37
37
  this.ui.body.scrolltop = 0
38
38
  }
39
39
 
40
- var route = this.buildRoute(page, size)
40
+ const route = this.buildRoute(page, size)
41
41
 
42
42
  if (more !== true && this.options.count) {
43
43
  this.requestCount(route)
@@ -45,7 +45,7 @@ export default {
45
45
 
46
46
  // console.log('route - ', this.rand, route)
47
47
 
48
- fetch(route, {signal}).then((resp) => {
48
+ fetch(route, { signal }).then((resp) => {
49
49
  return resp.json()
50
50
  }).then((data) => {
51
51
  if (this.options.debug) {
@@ -68,7 +68,7 @@ export default {
68
68
  }
69
69
 
70
70
  if (more === true) {
71
- var a = this.data.concat(data)
71
+ const a = this.data.concat(data)
72
72
  this.data = a
73
73
  this.storeData(data, more)
74
74
  this.virtual.add(this.data)
@@ -95,7 +95,7 @@ export default {
95
95
 
96
96
  requestCount (route, signal) {
97
97
  // console.log('fetchCount', route)
98
- fetch(route + '&count=1', {signal}).then((resp) => {
98
+ fetch(route + '&count=1', { signal }).then((resp) => {
99
99
  return resp.json()
100
100
  }).then((data) => {
101
101
  // console.log('data', data.count)
@@ -137,7 +137,7 @@ export default {
137
137
  page = page || 1
138
138
  size = size || this.options.list.size
139
139
 
140
- var route = this.options.route
140
+ let route = this.options.route
141
141
 
142
142
  if (path) {
143
143
  route = this.options.route[path]
@@ -154,7 +154,7 @@ export default {
154
154
 
155
155
  }
156
156
 
157
- if (this.ui.filter && this.ui.filter.root.classList.contains('selected')) {
157
+ if (this.ui.filter && this.ui.filter.element.classList.contains('selected')) {
158
158
  route = this.addParams(route, this.getFilter())
159
159
  }
160
160
 
@@ -174,7 +174,7 @@ export default {
174
174
  // console.log('storeData', this.dataStore)
175
175
  this.dataStore = this.dataStore || {}
176
176
 
177
- for (var i = 0; i < list.length; i++) {
177
+ for (let i = 0; i < list.length; i++) {
178
178
  this.dataList.push(list[i][this.dataId])
179
179
  this.dataStore[list[i][this.dataId]] = list[i]
180
180
  }
@@ -15,7 +15,7 @@ export default {
15
15
  }
16
16
 
17
17
  this.data = this.data || []
18
- var signal = null
18
+ let signal = null
19
19
 
20
20
  if (this.abortController) {
21
21
  this.abortController.abort()
@@ -34,7 +34,7 @@ export default {
34
34
  this.ui.body.scrolltop = 0
35
35
  }
36
36
 
37
- var route = this.buildRoute(page, size, 'search')
37
+ let route = this.buildRoute(page, size, 'search')
38
38
 
39
39
  route = this.addParams(route, 'search=' + keywords)
40
40
 
@@ -44,7 +44,7 @@ export default {
44
44
  this.requestCount(route)
45
45
  }
46
46
 
47
- fetch(route, {signal}).then((resp) => {
47
+ fetch(route, { signal }).then((resp) => {
48
48
  return resp.json()
49
49
  }).then((data) => {
50
50
  // console.log('data', data)
@@ -64,7 +64,7 @@ export default {
64
64
  }
65
65
 
66
66
  if (more === true) {
67
- var a = this.data.concat(data)
67
+ const a = this.data.concat(data)
68
68
  this.data = a
69
69
  this.storeData(data, more)
70
70
  this.virtual.add(this.data)
@@ -93,7 +93,7 @@ export default {
93
93
  toggleSearch (e) {
94
94
  e.stopPropagation()
95
95
  // console.log('toggle search', this.ui.body)
96
- if (!this.ui['search-input'].root.classList.contains('show')) {
96
+ if (!this.ui['search-input'].element.classList.contains('show')) {
97
97
  this.showSearch()
98
98
  } else {
99
99
  this.hideSearch()
@@ -114,13 +114,13 @@ export default {
114
114
  this.element.classList.add('search-mode')
115
115
 
116
116
  if (this.ui.search) {
117
- this.ui.search.root.classList.add('selected')
117
+ this.ui.search.element.classList.add('selected')
118
118
  }
119
119
 
120
120
  if (this.ui['search-input']) {
121
- this.ui['search-input'].input.value = ''
122
- this.ui['search-input'].root.classList.add('show')
123
- this.ui['search-input'].input.focus()
121
+ this.ui['search-input'].set()
122
+ this.ui['search-input'].show()
123
+ this.ui['search-input'].focus()
124
124
  }
125
125
 
126
126
  this.ui.body.innerHTML = ''
@@ -139,11 +139,11 @@ export default {
139
139
  this.element.classList.remove('search-mode')
140
140
 
141
141
  if (this.ui.search) {
142
- this.ui.search.root.classList.remove('selected')
142
+ this.ui.search.element.classList.remove('selected')
143
143
  }
144
144
  if (this.ui['search-input']) {
145
- this.ui['search-input'].root.classList.remove('show')
146
- this.ui['search-input'].input.value = ''
145
+ this.ui['search-input'].hide()
146
+ this.ui['search-input'].set()
147
147
  }
148
148
  // this.ui['search-list'].classList.remove('show')
149
149
  // this.ui.body.classList.remove('hide')
@@ -3,7 +3,7 @@ export default {
3
3
  // console.log('select', item.dataset.id)
4
4
  if (!item || !item.dataset.id) return
5
5
 
6
- var id = item.dataset.id
6
+ const id = item.dataset.id
7
7
 
8
8
  this.index = this.dataList.indexOf(id)
9
9
  this.info = this.dataStore[id]
@@ -12,7 +12,7 @@ export default {
12
12
  return
13
13
  }
14
14
 
15
- var selected = this.ui.body.querySelector('.selected')
15
+ const selected = this.ui.body.querySelector('.selected')
16
16
  if (selected) selected.classList.remove('selected')
17
17
 
18
18
  if (id) {
@@ -32,7 +32,7 @@ export default {
32
32
 
33
33
  unselect () {
34
34
  // console.log('unselect')
35
- var item = this.ui.body.querySelector('[data-id="' + this.id + '"]') || this.item
35
+ const item = this.ui.body.querySelector('[data-id="' + this.id + '"]') || this.item
36
36
  this.id = null
37
37
  if (item) {
38
38
  item.classList.remove('selected')
@@ -51,7 +51,7 @@ export default {
51
51
 
52
52
  getItemById (id, silent) {
53
53
  // console.log('selectItemById', id)
54
- var item = this.ui.body.querySelector('[data-id="' + id + '"]')
54
+ const item = this.ui.body.querySelector('[data-id="' + id + '"]')
55
55
 
56
56
  if (!item) {
57
57
  return null
@@ -67,7 +67,7 @@ export default {
67
67
  return false
68
68
  }
69
69
 
70
- var index = this.dataList.indexOf(id)
70
+ const index = this.dataList.indexOf(id)
71
71
  if (index < 0) {
72
72
  // console.log('can\'t selectid, not in the list')
73
73
  return false
@@ -83,16 +83,16 @@ export default {
83
83
 
84
84
  selectItemById (id, direction) {
85
85
  // console.log('selectItemById', id)
86
- var item = this.ui.body.querySelector('[data-id="' + id + '"]')
86
+ const item = this.ui.body.querySelector('[data-id="' + id + '"]')
87
87
 
88
88
  this.id = id
89
89
 
90
90
  if (!item) {
91
- var index = this.dataList.indexOf(id)
91
+ const index = this.dataList.indexOf(id)
92
92
  // console.log('not found in DOM, check in dataList', index)
93
93
  if (index > -1) {
94
- var listSize = this.options.list.size
95
- var slice = listSize * index / listSize
94
+ const listSize = this.options.list.size
95
+ const slice = listSize * index / listSize
96
96
  // console.log('getSlice', slice)
97
97
  }
98
98
 
@@ -103,7 +103,7 @@ export default {
103
103
 
104
104
  // if (this.item) this.item.classList.remove('selected')
105
105
 
106
- var selected = this.ui.body.querySelector('.selected')
106
+ const selected = this.ui.body.querySelector('.selected')
107
107
  if (selected) selected.classList.remove('selected')
108
108
 
109
109
  this.item = item
@@ -118,7 +118,7 @@ export default {
118
118
  },
119
119
 
120
120
  selectPosition (item, direction) {
121
- var offsetY = this.options.item.height
121
+ const offsetY = this.options.item.height
122
122
  direction = direction || 'down'
123
123
  // console.log('selectPosition', this.ui.body, direction)
124
124
 
@@ -126,12 +126,12 @@ export default {
126
126
 
127
127
  // console.log('coord', this.coord)
128
128
 
129
- var itemTop = item.offsetTop + this.coord.top - this.ui.body.scrollTop
129
+ const itemTop = item.offsetTop + this.coord.top - this.ui.body.scrollTop
130
130
 
131
131
  if (direction === 'down' && itemTop + this.options.item.height + offsetY - this.coord.y > this.coord.height) {
132
132
  var top = this.ui.body.scrollTop + itemTop - this.coord.height - this.coord.y + this.options.item.height + offsetY
133
133
  this.ui.body.scrollTo({
134
- top: top,
134
+ top,
135
135
  left: 0
136
136
  // behavior: 'smooth'
137
137
  })
@@ -142,7 +142,7 @@ export default {
142
142
  // console.lof('scrollTo', top, item)
143
143
  this.ui.body.scrollTo({
144
144
  left: 0,
145
- top: top
145
+ top
146
146
  // behavior: 'smooth'
147
147
  })
148
148
  }
@@ -150,9 +150,9 @@ export default {
150
150
 
151
151
  selectNext (silent) {
152
152
  // console.log('selectNext', this.id)
153
- var idx = this.dataList.indexOf(this.id)
153
+ const idx = this.dataList.indexOf(this.id)
154
154
 
155
- var id = this.dataList[idx + 1]
155
+ const id = this.dataList[idx + 1]
156
156
 
157
157
  // console.log('id', id)
158
158
 
@@ -172,9 +172,9 @@ export default {
172
172
 
173
173
  selectPrevious (silent) {
174
174
  // console.log('selectPrevious', this.id)
175
- var idx = this.dataList.indexOf(this.id)
175
+ const idx = this.dataList.indexOf(this.id)
176
176
 
177
- var id = this.dataList[idx - 1]
177
+ const id = this.dataList[idx - 1]
178
178
 
179
179
  if (id) {
180
180
  this.id = id
@@ -9,7 +9,7 @@ export default {
9
9
 
10
10
  statusCount (count) {
11
11
  // console.log('statusCount', count)
12
- var items = 'items'
12
+ let items = 'items'
13
13
  if (this.status && this.status.count && this.status.count.name) {
14
14
  items = this.status.count.name
15
15
  }
@@ -9,8 +9,8 @@ export default {
9
9
 
10
10
  getUpdatedIndex (id) {
11
11
  // console.log('getUpdatedIndex', id)
12
- var index = null
13
- for (var i = 0; i < this.data.length; i++) {
12
+ let index = null
13
+ for (let i = 0; i < this.data.length; i++) {
14
14
  // console.log('--', this.data[i][this.dataId], id)
15
15
  if (this.data[i][this.dataId] === id) {
16
16
  index = i
@@ -23,9 +23,9 @@ export default {
23
23
 
24
24
  getUpdatedInfo (id) {
25
25
  // console.log('getUpdatedInfo', id)
26
- var index = this.getUpdatedIndex(id)
26
+ const index = this.getUpdatedIndex(id)
27
27
  // console.log('index', index)
28
- var route = this.buildRoute(index + 1, 1)
28
+ const route = this.buildRoute(index + 1, 1)
29
29
  // console.log('roote', route)
30
30
  fetch(route).then((resp) => {
31
31
  return resp.json()
@@ -50,10 +50,10 @@ export default {
50
50
  this.dataStore[info[this.dataId]] = info
51
51
 
52
52
  // update item if on the screen
53
- var item = this.ui.body.querySelector('[data-id="' + info[this.dataId] + '"]')
53
+ const item = this.ui.body.querySelector('[data-id="' + info[this.dataId] + '"]')
54
54
  if (item) {
55
55
  item.innerHTML = ''
56
- var layout = new Layout(this.options.layout.item, item)
56
+ const layout = new Layout(this.options.layout.item, item)
57
57
 
58
58
  this.renderInfo(layout, info)
59
59
  }
@@ -39,14 +39,14 @@ function VirtualList (options) {
39
39
  VirtualList.prototype._renderChunk = function (node, from, number) {
40
40
  // console.log('_renderChunk', from, number, this.options.class)
41
41
 
42
- var fragment = document.createDocumentFragment()
42
+ const fragment = document.createDocumentFragment()
43
43
  fragment.appendChild(this.scroller)
44
44
 
45
- var last = from + number
45
+ let last = from + number
46
46
  if (last > this.count) last = this.count
47
47
 
48
- for (var i = from; i < last; i++) {
49
- var item = this.render(i)
48
+ for (let i = from; i < last; i++) {
49
+ const item = this.render(i)
50
50
 
51
51
  item.style.position = 'absolute'
52
52
  item.style.top = i * this.itemHeight + 'px'
@@ -84,7 +84,7 @@ VirtualList.prototype.set = function (items) {
84
84
  this.container.innerHTML = ''
85
85
  this.container.scrollTop = 0
86
86
 
87
- var height = this.itemHeight * this.count
87
+ const height = this.itemHeight * this.count
88
88
 
89
89
  this.scroller.style.height = height + 'px'
90
90
 
@@ -94,7 +94,7 @@ VirtualList.prototype.set = function (items) {
94
94
  // console.log('this.itemsByScreen', this.itemsByScreen)
95
95
 
96
96
  // Cache 4 times the number of items that fit in the container viewport
97
- var size = this.itemsByScreen * 4
97
+ let size = this.itemsByScreen * 4
98
98
  this._renderChunk(this.container, 0, size)
99
99
 
100
100
  this.size = size
@@ -102,13 +102,13 @@ VirtualList.prototype.set = function (items) {
102
102
  // console.log('emit size', size)
103
103
  this.emit('size', size)
104
104
 
105
- var self = this
106
- var lastRepaintY
107
- var maxBuffer = this.itemsByScreen * this.itemHeight
105
+ const self = this
106
+ let lastRepaintY
107
+ const maxBuffer = this.itemsByScreen * this.itemHeight
108
108
 
109
109
  function onScroll (e) {
110
110
  // console.log('scroll', e.target.scrollTop, height)
111
- var scrollTop = e.target.scrollTop
111
+ const scrollTop = e.target.scrollTop
112
112
 
113
113
  // console.log('itemsByScreen', self.itemsByScreen)
114
114
 
@@ -124,7 +124,7 @@ VirtualList.prototype.set = function (items) {
124
124
 
125
125
  // console.log('itemsByScreen', self.itemsByScreen)
126
126
 
127
- var first = parseInt(scrollTop / self.itemHeight) - self.itemsByScreen
127
+ let first = parseInt(scrollTop / self.itemHeight) - self.itemsByScreen
128
128
  first = first < 0 ? 0 : first
129
129
 
130
130
  size = self.itemsByScreen * 4
@@ -134,7 +134,7 @@ VirtualList.prototype.set = function (items) {
134
134
  lastRepaintY = scrollTop
135
135
  }
136
136
 
137
- var progress = Math.ceil((scrollTop / self.itemHeight) + self.itemsByScreen) - 1
137
+ const progress = Math.ceil((scrollTop / self.itemHeight) + self.itemsByScreen) - 1
138
138
  // console.log('progress', progress)
139
139
  self.emit('progress', progress)
140
140
 
@@ -160,14 +160,14 @@ VirtualList.prototype.update = function (items) {
160
160
  this.count = this.items.length
161
161
 
162
162
  // var itemsByScreen = Math.ceil(this.container.offsetHeight / this.itemHeight)
163
- var cachedItemsLen = this.itemsByScreen * 4
164
- var scrollTop = this.container.scrollTop
163
+ const cachedItemsLen = this.itemsByScreen * 4
164
+ const scrollTop = this.container.scrollTop
165
165
 
166
- var height = this.itemHeight * this.count
166
+ const height = this.itemHeight * this.count
167
167
 
168
168
  this.scroller.style.height = height + 'px'
169
169
 
170
- var first = parseInt(scrollTop / this.itemHeight) - this.itemsByScreen
170
+ let first = parseInt(scrollTop / this.itemHeight) - this.itemsByScreen
171
171
  first = first < 0 ? 0 : first
172
172
 
173
173
  // console.log('first', first, cachedItemsLen)
@@ -183,7 +183,7 @@ VirtualList.prototype.add = function (items) {
183
183
 
184
184
  this.count = this.items.length
185
185
 
186
- var height = this.itemHeight * this.count
186
+ const height = this.itemHeight * this.count
187
187
 
188
188
  this.scroller.style.height = height + 'px'
189
189
  }
@@ -212,10 +212,10 @@ VirtualList.prototype.setOffset = function (info) {
212
212
 
213
213
  // console.log('new itemsByScreen', this.itemsByScreen)
214
214
 
215
- var itemsByScreen = Math.ceil(this.offsetHeight / this.itemHeight)
215
+ const itemsByScreen = Math.ceil(this.offsetHeight / this.itemHeight)
216
216
 
217
217
  // Cache 4 times the number of items that fit in the container viewport
218
- var size = itemsByScreen * 4
218
+ const size = itemsByScreen * 4
219
219
 
220
220
  return size
221
221
  }
@@ -227,7 +227,7 @@ VirtualList.prototype.getCount = function () {
227
227
  }
228
228
 
229
229
  VirtualList.createScroller = function () {
230
- var scroller = document.createElement('div')
230
+ const scroller = document.createElement('div')
231
231
  scroller.classList.add('scroller')
232
232
  return scroller
233
233
  }
@@ -1,15 +1,15 @@
1
1
  // based on https://sergimansilla.com/blog/virtual-scrolling/
2
2
 
3
3
  // Import necessary modules
4
- import passiveEvents from '../module/passive' // Import the passiveEvents utility.
5
- import emitter from '../module/emitter' // Import the emitter module.
4
+ import passiveEvents from '../module/passive' // Import the passiveEvents utility.
5
+ import emitter from '../module/emitter' // Import the emitter module.
6
6
 
7
7
  // Define the VirtualList class
8
8
  class VirtualList {
9
9
  constructor (options) {
10
10
  // Initialize the class with options passed to the constructor.
11
- this.options = { ...(options || {}) } // Spread operator to merge options with default values.
12
- Object.assign(this, emitter) // Assign emitter methods to the instance.
11
+ this.options = { ...(options || {}) } // Spread operator to merge options with default values.
12
+ Object.assign(this, emitter) // Assign emitter methods to the instance.
13
13
 
14
14
  // Destructure options for easier access to properties.
15
15
  const { itemHeight = 0, size = 0, items = [], render, container } = options
@@ -103,7 +103,7 @@ class VirtualList {
103
103
  // Add a scroll event listener to render items dynamically.
104
104
  const onScroll = (e) => {
105
105
  const scrollTop = e.target.scrollTop
106
- let first = parseInt(scrollTop / this.itemHeight) - this.itemsByScreen
106
+ const first = parseInt(scrollTop / this.itemHeight) - this.itemsByScreen
107
107
 
108
108
  size = this.itemsByScreen * 4
109
109