@rjlevy/

Vue: simplebar

HTML, CSS, JS

No description

fork
loading
Files
  • index.html
  • reference.txt
  • script.js
  • styles.css
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width">
	<title>Simplebar Vue</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  <link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/simplebar.css" />
</head>

<body>

	<div id="app">
    <!-- <say-hello></say-hello> -->
    
    <simplebar>
      <div>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
      </div>
    </simplebar>
    
  </div>

  <template id="hello-template">
    <h2>
      Hello!
    </h2>
  </template>

  <template id="simplebar-vue">
    <div ref="element">
    <!-- {{ JSON.stringify(test, null, 2) }} -->
       <div class="simplebar-wrapper">
          <div class="simplebar-height-auto-observer-wrapper">
            <div class="simplebar-height-auto-observer" />
          </div>
          <div class="simplebar-mask">
            <div class="simplebar-offset">
              <div class="simplebar-content-wrapper" ref="scrollElement">
                <div class="simplebar-content" ref="contentElement">
                  <slot></slot>
                </div>
              </div>
            </div>
          </div>
          <div class="simplebar-placeholder" />
        </div>
        <div class="simplebar-track simplebar-horizontal">
          <div class="simplebar-scrollbar" />
        </div>
        <div class="simplebar-track simplebar-vertical">
          <div class="simplebar-scrollbar" />
        </div>
    </div>
  </template>

	<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  <script src="https://unpkg.com/[email protected]/dist/simplebar.min.js"></script>	
	<script src="script.js"></script>

<script>

  const Simplebar = {
    name: 'simplebar-vue',
    template: '#simplebar-vue',
    data: () => ({
      // test: 'working...'
    }),
    mounted () {
      const options = SimpleBar.getElOptions(this.$refs.element);
      this.SimpleBar = new SimpleBar(this.$refs.element, options);
    },
    computed: {
      scrollElement () {
        return this.$refs.scrollElement;
      },
      contentElement () {
        return this.$refs.contentElement;
      }
    }
  }
  const SayHello = {    
    name: 'hello',
    template: '#hello-template'
  }

  const vm = new Vue({
    el: '#app',
    name: "App",
    components: {
      SayHello,
      Simplebar
    }
  });

</script>

</body>

</html>
result
console