VOOZH about

URL: https://quasar.dev/vue-directives/scroll/

⇱ Directive v-scroll | Quasar Framework


assignment_late
Why donate
travel_explore
API Explorer
build
Quasar CLI (with Vite)
Upgrade Guide
Creating a New Project
The /quasar.config File
Convert q/app-webpack Project
Browser Compatibility
TypeScript Support
Directory Structure
Commands List
CSS Preprocessors
Page Routing with VueRouter
Lazy Loading - Code Splitting
Handling Assets
Boot Files
Prefetch Feature
API Proxying
Handling Vite
Handling import.meta.env
State Management with Pinia
Lint and Format Code
Testing & Auditing
Developing Mobile Apps
Ajax Requests
Opening Dev Server To Public
build
Quasar CLI (with Webpack)
Directive v-scroll

This is a Vue directive which takes one parameter (a Function) and fires when user scrolls the page containing that DOM node.

TIPS

  • One alternative to using this directive is to place a QScrollObserver component on your page.
  • There is one more scrolling-related directive available called Scroll Fire.
Loading Scroll API...

Usage

<template>
 ...
 <div v-scroll="onScroll">...</div>
 ...
</template>

<script setup>
 function onScroll(position) {
 // when this method is invoked then it means user
 // has scrolled the page to `position`
 //
 // `position` is an Integer designating the current
 // scroll position in pixels.
 }
</script>
<template>
 ...
 <div v-scroll="onScroll">...</div>
 ...
</template>

<script setup>
 import { debounce } from 'quasar'

 const onScroll = debounce(position => {
 // when this method is invoked then it means user
 // has scrolled the page to `position`
 //
 // `position` is an Integer designating the current
 // scroll position in pixels.
 }, 200) // debounce for 200ms
</script>

Determining Scrolling Container

Please read here about how Quasar determines the container to attach scrolling events to.


Caught a mistake?Edit this page in browser
1. Introduction
2. Scroll API
3. Usage
3.1. Determining Scrolling Container
Copyright © 2015-present PULSARDEV SRL, Razvan Stoenescu