scrivito_section_widgets 0.0.17 → 0.0.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/scrivito_section_widgets/parallax.js +9 -33
- data/app/assets/stylesheets/scrivito_section_widgets/bootstrap_sectionize.css +0 -49
- data/app/assets/stylesheets/scrivito_section_widgets/parallax_section.css +4 -4
- data/app/models/section_parallax_widget.rb +20 -0
- data/app/views/section_parallax_widget/show.html.erb +4 -2
- data/lib/scrivito_section_widgets/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f3556de3c06d11e61196238f2e7e156702d7c79
|
4
|
+
data.tar.gz: 95c492f668b7092f07a1f51addd9591f9c8e4aaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f62862dd4ffed46a83c813a0fe9e4c4178be010c0f52c8a53ab73965680aec594b440115c9569e6f0e6f5d3bc8ea74922720c2757e9b2f94f5a5b22550d3011e
|
7
|
+
data.tar.gz: 8f53de1070b57fa3da8e93744d378ee30111d08e62372f37aa31dacbf8829436c75612ca814b89fa44762668b8927064e40ac102bd059a04911b1d2b505df60b
|
@@ -7,7 +7,7 @@ $(function(){
|
|
7
7
|
|| function(f){setTimeout(f, 1000/60)}
|
8
8
|
|
9
9
|
scrivito.on('content', function() {
|
10
|
-
var images = $(".parallax-image");
|
10
|
+
var images = $(".parallax-image-fast, .parallax-image-medium, .parallax-image-slow");
|
11
11
|
|
12
12
|
if($('body').width() > 1024) {
|
13
13
|
set_background_positions(images);
|
@@ -15,32 +15,10 @@ $(function(){
|
|
15
15
|
$(window).on('scroll', function(event) {
|
16
16
|
window.requestAnimationFrame(function(){ set_background_positions(images); });
|
17
17
|
});
|
18
|
-
} else {
|
19
|
-
set_dimension(images);
|
20
18
|
}
|
21
|
-
|
22
|
-
$(window).on('resize', function(event) {
|
23
|
-
set_dimension(images);
|
24
|
-
});
|
25
19
|
});
|
26
20
|
});
|
27
21
|
|
28
|
-
function set_dimension(images) {
|
29
|
-
var height = 0;
|
30
|
-
var container = null;
|
31
|
-
|
32
|
-
$.each(images, function(i, image) {
|
33
|
-
container = $(image).parents('.parallax');
|
34
|
-
height = $(image).get(0).clientHeight / 1.3;
|
35
|
-
|
36
|
-
if(height > 0) {
|
37
|
-
container.css({
|
38
|
-
'height': height,
|
39
|
-
});
|
40
|
-
}
|
41
|
-
});
|
42
|
-
}
|
43
|
-
|
44
22
|
function set_background_positions(images) {
|
45
23
|
$.each(images, function(i, image) {
|
46
24
|
set_background_position(image);
|
@@ -49,16 +27,14 @@ function set_background_positions(images) {
|
|
49
27
|
|
50
28
|
function set_background_position(image) {
|
51
29
|
var value = $(image).data('parallax-speed');
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
});
|
61
|
-
}
|
30
|
+
var data = calulate_position(image, value);
|
31
|
+
$(image).css({
|
32
|
+
'-webkit-transform': data,
|
33
|
+
'-ms-transform': data,
|
34
|
+
'-o-transform': data,
|
35
|
+
'-moz-transform': data,
|
36
|
+
'transform': data,
|
37
|
+
});
|
62
38
|
}
|
63
39
|
|
64
40
|
function calulate_position(image, value) {
|
@@ -1,52 +1,3 @@
|
|
1
|
-
.container {
|
2
|
-
width: 100%;
|
3
|
-
padding: 0;
|
4
|
-
margin: 0;
|
5
|
-
}
|
6
|
-
|
7
|
-
#wrap > .container {
|
8
|
-
overflow: hidden;
|
9
|
-
width: 100%;
|
10
|
-
margin: 0;
|
11
|
-
padding: 0;
|
12
|
-
}
|
13
|
-
|
14
|
-
section .container {
|
15
|
-
width: 100%;
|
16
|
-
padding: 15px;
|
17
|
-
margin: 0 auto;
|
18
|
-
}
|
19
|
-
|
20
1
|
.navbar {
|
21
2
|
margin-bottom: 0 !important;
|
22
3
|
}
|
23
|
-
|
24
|
-
@media (min-width: 768px) {
|
25
|
-
.container {
|
26
|
-
width: 100%;
|
27
|
-
}
|
28
|
-
|
29
|
-
section .container {
|
30
|
-
width: 750px;
|
31
|
-
}
|
32
|
-
}
|
33
|
-
|
34
|
-
@media (min-width: 992px) {
|
35
|
-
.container {
|
36
|
-
width: 100%;
|
37
|
-
}
|
38
|
-
|
39
|
-
section .container {
|
40
|
-
width: 970px;
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
@media (min-width: 1220px) {
|
45
|
-
.container {
|
46
|
-
width: 100%;
|
47
|
-
}
|
48
|
-
|
49
|
-
section .container {
|
50
|
-
width: 1170px;
|
51
|
-
}
|
52
|
-
}
|
@@ -11,15 +11,15 @@
|
|
11
11
|
height: auto;
|
12
12
|
}
|
13
13
|
|
14
|
-
.scrivito_section_parallax_widget.parallax_speed_fixed .parallax-image {
|
15
|
-
position: fixed;
|
16
|
-
}
|
17
|
-
|
18
14
|
.scrivito_section_video_widget video {
|
19
15
|
width: 100%;
|
20
16
|
display: block;
|
21
17
|
}
|
22
18
|
|
19
|
+
.section_speed_fixed {
|
20
|
+
background-size: cover !important;
|
21
|
+
}
|
22
|
+
|
23
23
|
.scrivito_section_video_widget .container {
|
24
24
|
position: absolute;
|
25
25
|
top: 0;
|
@@ -3,4 +3,24 @@ class SectionParallaxWidget < Widget
|
|
3
3
|
attribute :background_image, :reference
|
4
4
|
attribute :height, :string
|
5
5
|
attribute :speed, :enum, values: ["fixed", "slow", "medium", "fast", "deactivate"], default: "medium"
|
6
|
+
|
7
|
+
def section_class
|
8
|
+
"parallax scrivito_section_parallax_widget section_speed_#{speed}"
|
9
|
+
end
|
10
|
+
|
11
|
+
def section_style
|
12
|
+
styles = "height: #{height}; max-height: #{height};"
|
13
|
+
styles += "background: url(#{background_image.binary_url}) top center #{'fixed' if speed=='fixed'} no-repeat;" unless with_parallax?
|
14
|
+
return styles
|
15
|
+
end
|
16
|
+
|
17
|
+
def with_parallax?
|
18
|
+
return true unless speed.present?
|
19
|
+
["slow", "medium", "fast"].include? speed
|
20
|
+
end
|
21
|
+
|
22
|
+
def parallax_speed
|
23
|
+
# legacy support for widgets before speed option
|
24
|
+
speed.presence || 'medium'
|
25
|
+
end
|
6
26
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
<section class="
|
2
|
-
|
1
|
+
<section class="<%= widget.section_class %>" style="<%= widget.section_style %>">
|
2
|
+
<% if widget.with_parallax? %>
|
3
|
+
<%= scrivito_image_tag(widget, :background_image, class: "parallax-image parallax-image-#{widget.parallax_speed}", data: { parallax_speed: widget.speed }) %>
|
4
|
+
<% end %>
|
3
5
|
<%= scrivito_tag(:div, widget, :section_content, class: 'container') %>
|
4
6
|
</section>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scrivito_section_widgets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scrivito
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|