From f8c509fdebfca51bda28b5d204728fa5da59012f Mon Sep 17 00:00:00 2001 From: "Mr. Will" Date: Tue, 27 Aug 2024 20:51:01 +0800 Subject: [PATCH] Move code about Lenis to a separate js file --- layout/_partial/head.ejs | 11 +---------- source/js/smooth-scroll.js | 8 ++++++++ 2 files changed, 9 insertions(+), 10 deletions(-) create mode 100644 source/js/smooth-scroll.js diff --git a/layout/_partial/head.ejs b/layout/_partial/head.ejs index dbcafec..faff049 100644 --- a/layout/_partial/head.ejs +++ b/layout/_partial/head.ejs @@ -123,16 +123,7 @@ <% if (theme.smooth_scroll) { %> <%- css(getCdnUrl('lenis', '1.1.9', 'dist/lenis.css')) %> - + <%- js('js/smooth-scroll.js') %> <% } %> <% if (config.waline) { %> diff --git a/source/js/smooth-scroll.js b/source/js/smooth-scroll.js new file mode 100644 index 0000000..627ea25 --- /dev/null +++ b/source/js/smooth-scroll.js @@ -0,0 +1,8 @@ +const lenis = new Lenis() + +function raf(time) { + lenis.raf(time) + requestAnimationFrame(raf) +} + +requestAnimationFrame(raf)