gpt4 book ai didi

javascript - rails 4 : View Doesn't Scroll when using One Page Scroll v1. 3

转载 作者:太空宇宙 更新时间:2023-11-04 03:42:37 28 4
gpt4 key购买 nike

您好,我正在使用 Rails,我正在尝试使用此处显示的 One Page Scroll 插件:http://www.thepetedesign.com/demos/onepage_scroll_demo.html

我有一个几乎是空白的应用程序(就 View 和样式表而言)。这是当前不滚动的页面的布局和 View :

layouts/application.html.erb

<!DOCTYPE html>
<html>
<head>
<title>Lorem</title>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
</head>
<body>
<div class='main'> <!--One Page! -->
<div class='row'>
<div id='tasmbloch'>
<div id='id'>
<%= image_tag 'ban_Trans.png' %>
</div>
</div>
</div>

<%= yield %>
</div>
</body>
</html>

对应的 View :

<div class='section'>
<%= image_tag "lorem_borem.png"%>
</div>
<div class='section'>
Lorem ipsum dolor sit amet, consectetur adipisicing 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>

我在我的 app/assets/ javascripts 和 stylesheets 目录中包含了 javascript 和一页滚动对应的css。我在调用插件的 jQuery 片段中写了一个 console.log() 语句来确认它被调用了,确实如此。

这是通过 application.css

间接包含的单页滚动 css
body, html {
margin: 0;
overflow: hidden;
-webkit-transition: opacity 400ms;
-moz-transition: opacity 400ms;
transition: opacity 400ms;
}

body, .onepage-wrapper, html {
display: block;
position: static;
padding: 0;
width: 100%;
height: 100%;
}

.onepage-wrapper {
width: 100%;
height: 100%;
display: block;
position: relative;
padding: 0;
-webkit-transform-style: preserve-3d;
}

.onepage-wrapper .section {
width: 100%;
height: 100%;
}

.onepage-pagination {
position: absolute;
right: 10px;
top: 50%;
z-index: 5;
list-style: none;
margin: 0;
padding: 0;
}
.onepage-pagination li {
padding: 0;
text-align: center;
}
.onepage-pagination li a{
padding: 10px;
width: 4px;
height: 4px;
display: block;

}
.onepage-pagination li a:before{
content: '';
position: absolute;
width: 4px;
height: 4px;
background: rgba(0,0,0,0.85);
border-radius: 10px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
}

.onepage-pagination li a.active:before{
width: 10px;
height: 10px;
background: none;
border: 1px solid black;
margin-top: -4px;
left: 8px;
}

.disabled-onepage-scroll, .disabled-onepage-scroll .wrapper {
overflow: auto;
}

.disabled-onepage-scroll .onepage-wrapper .section {
position: relative !important;
top: auto !important;
left: auto !important;
}
.disabled-onepage-scroll .onepage-wrapper {
-webkit-transform: none !important;
-moz-transform: none !important;
transform: none !important;
-ms-transform: none !important;
min-height: 100%;
}

.disabled-onepage-scroll .onepage-pagination { 显示:无;

body.disabled-onepage-scroll, .disabled-onepage-scroll .onepage-wrapper, html {
position: inherit;
}

最佳答案

知道这是一个旧帖子,但遇到了同样的问题。我认为您的问题是因为您让插件可以执行以下操作:

调用<head></head>中的函数,不是页脚:

...
<script>
$(document).ready(function(){
$(".main").onepage_scroll({
sectionContainer: "section",
easing: "ease",

animationTime: 1000,
pagination: true,
updateURL: false,
beforeMove: function(index) {},
afterMove: function(index) {},
loop: false,
keyboard: true,
responsiveFallback: false,
direction: "vertical"
});
...
</script>

从那时起,一切对我来说就像一种魅力。

关于javascript - rails 4 : View Doesn't Scroll when using One Page Scroll v1. 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24664934/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com