0.0.21 • Published 1 year ago

@mrzlanx532/nuxt-3-custom-scroll-plugin v0.0.21

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Установка

Общее

npm i @mrzlanx532/nuxt-3-custom-scroll-plugin

Установка в модуль Nuxt 3

import { defineNuxtPlugin, onNuxtReady } from '#app'

import 'nuxt-3-custom-scroll-plugin/assets/common.css'

/** Установка v-scrollable директивы + css */
import { Scrollable } from 'nuxt-3-custom-scroll-plugin'
import 'nuxt-3-custom-scroll-plugin/assets/v-scrollable.css'

/** Установка DocumentScroll + css */
import { DocumentScroll } from 'nuxt-3-custom-scroll-plugin'
import 'nuxt-3-custom-scroll-plugin/assets/document-scroll.no-ssr.css'

export default defineNuxtPlugin((nuxtApp) => {
    nuxtApp.vueApp.directive('scrollable', {
        mounted: function (el, binding) {
            new Scrollable(el, binding.value)
        }
    })
    onNuxtReady(async () => {
        window.documentScroll = new DocumentScroll

        try {
            new ResizeObserver(() => {
                window.documentScroll.updateScroll()
            }).observe(document.documentElement)
        } catch (e) {
            console.warn('Не удалось установить ResizeObserver для document')
        }
    })
})

Использование v-scrollable

inheritanceDimensions: true

Позволяет перенести размеры оборачиваемого элемента в обертку v-scrollable.
А именно: забрать maxHeight, maxWidth, height, width

<div class="modal__container" v-scrollable="{inheritanceDimensions: true}">
  <div class="content" style="height: 1800px;">
    <button>Подтвердить?</button>
  </div>
</div>

CSS Variables

Scrollable

:root {
    --scrollable-track-background: transparent;
    --scrollable-slider-background: transparent;    
}

DocumentScroll

:root {
    --document-scroll-border-radius: 5px;
    --document-scroll-thickness: 4px;
    --document-scroll-background: grey;
    --document-scroll-track-background: transparent;
    --document-scroll-track-border-radius: 0;
    --document-scroll-thickness-hover-active: 8px;    
}

Разработка и дебаг

cd ./playground && npm install && npm run dev

0.0.21

1 year ago

0.0.20

1 year ago

0.0.19

1 year ago

0.0.18

1 year ago

0.0.17

1 year ago

0.0.16

1 year ago

0.0.15

1 year ago

0.0.14

1 year ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago