728x90

https://www.npmjs.com/package/scroll-lock

 

scroll-lock

Cross-browser JavaScript library to disable scrolling page.. Latest version: 2.1.5, last published: 2 years ago. Start using scroll-lock in your project by running `npm i scroll-lock`. There are 29 other projects in the npm registry using scroll-lock.

www.npmjs.com

 

기능 : 배경 스크롤 기능을 막아줌

주 사용처 : 팝업 띄울때 배경 스크롤 막기

특징 : 다양한 플랫폼 지원 (IOS에서 정상동작해줌)

주의할점 : enablePageScroll, disablePageScroll을 꼭 제대로 지정해줘야함 

 

// vue 사용 예시
<template>
  <div ref="target"></div>
</template>

<script>
import { disablePageScroll, enablePageScroll } from "scroll-lock";
export default {
  mounted() {
    this.$nextTick(function () {
      disablePageScroll(this.$refs.target);      
    });
  },
  beforeDestroy() {    
    enablePageScroll(this.$refs.target);
  },  
};
</script>

 

728x90

+ Recent posts