scrivito_section_widgets 0.0.16 → 0.0.17
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 +43 -31
- data/app/assets/stylesheets/scrivito_section_widgets/parallax_section.css +4 -0
- data/app/models/section_parallax_widget.rb +1 -0
- data/app/views/section_parallax_widget/details.html.erb +4 -0
- data/app/views/section_parallax_widget/show.html.erb +2 -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: 51fbd2e71f117e6c7c4c2bea949c20836795d98f
|
4
|
+
data.tar.gz: ab9a2a08e8a690dbd9e07af85dae04accb06206c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dced368dddc188d551226899ee057d4b49e99d5d74985c4f486a74b6ef38df3f3174ee81823c36725cec52cb64c283c5d58592c2dea3df5103f583278323ee66
|
7
|
+
data.tar.gz: 570b120430a4dd05e06a73d59cfd5b6cb5d9d96471df424777a0ccd938e8389904bbc214adc44473ab9ac1c3a9792aaf67d0058013e19822618b020041dc3049
|
@@ -6,30 +6,32 @@ $(function(){
|
|
6
6
|
|| window.msRequestAnimationFrame
|
7
7
|
|| function(f){setTimeout(f, 1000/60)}
|
8
8
|
|
9
|
-
|
9
|
+
scrivito.on('content', function() {
|
10
|
+
var images = $(".parallax-image");
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
if($('body').width() > 1024) {
|
13
|
+
set_background_positions(images);
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
$(window).on('scroll', function(event) {
|
16
|
+
window.requestAnimationFrame(function(){ set_background_positions(images); });
|
17
|
+
});
|
18
|
+
} else {
|
19
|
+
set_dimension(images);
|
20
|
+
}
|
20
21
|
|
21
|
-
|
22
|
-
|
22
|
+
$(window).on('resize', function(event) {
|
23
|
+
set_dimension(images);
|
24
|
+
});
|
23
25
|
});
|
24
26
|
});
|
25
27
|
|
26
|
-
function set_dimension(
|
28
|
+
function set_dimension(images) {
|
27
29
|
var height = 0;
|
28
30
|
var container = null;
|
29
31
|
|
30
|
-
$.each(
|
31
|
-
container = $(
|
32
|
-
height = $(
|
32
|
+
$.each(images, function(i, image) {
|
33
|
+
container = $(image).parents('.parallax');
|
34
|
+
height = $(image).get(0).clientHeight / 1.3;
|
33
35
|
|
34
36
|
if(height > 0) {
|
35
37
|
container.css({
|
@@ -39,28 +41,38 @@ function set_dimension(elems) {
|
|
39
41
|
});
|
40
42
|
}
|
41
43
|
|
42
|
-
function set_background_positions(
|
43
|
-
$.each(
|
44
|
-
set_background_position(
|
44
|
+
function set_background_positions(images) {
|
45
|
+
$.each(images, function(i, image) {
|
46
|
+
set_background_position(image);
|
45
47
|
});
|
46
48
|
}
|
47
49
|
|
48
|
-
function set_background_position(
|
49
|
-
$(
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
50
|
+
function set_background_position(image) {
|
51
|
+
var value = $(image).data('parallax-speed');
|
52
|
+
if(!(value == "fixed" || value == "deactivate")) {
|
53
|
+
var data = calulate_position(image, value);
|
54
|
+
$(image).css({
|
55
|
+
'-webkit-transform': data,
|
56
|
+
'-ms-transform': data,
|
57
|
+
'-o-transform': data,
|
58
|
+
'-moz-transform': data,
|
59
|
+
'transform': data,
|
60
|
+
});
|
61
|
+
}
|
56
62
|
}
|
57
63
|
|
58
|
-
function calulate_position(
|
59
|
-
var speed =
|
60
|
-
var value = (caluclate_offset(
|
64
|
+
function calulate_position(image, value) {
|
65
|
+
var speed = data_to_speed(value);
|
66
|
+
var value = (caluclate_offset(image) * speed) + "px";
|
61
67
|
return 'translate3d(0px, '+ value +', 0px)'
|
62
68
|
}
|
63
69
|
|
64
|
-
function caluclate_offset(
|
65
|
-
return window.pageYOffset - $(
|
70
|
+
function caluclate_offset(image) {
|
71
|
+
return window.pageYOffset - $(image).offset().top;
|
66
72
|
}
|
73
|
+
|
74
|
+
function data_to_speed(value) {
|
75
|
+
if(value == "fast") return 0.6;
|
76
|
+
if(value == "slow") return 0.1;
|
77
|
+
return 0.3;
|
78
|
+
}
|
@@ -2,6 +2,10 @@
|
|
2
2
|
<%= scrivito_tag(:div, widget, :background_image) %>
|
3
3
|
<% end %>
|
4
4
|
|
5
|
+
<%= scrivito_details_for 'Speed' do %>
|
6
|
+
<%= scrivito_toggle_button_editor(widget, :speed) %>
|
7
|
+
<% end %>
|
8
|
+
|
5
9
|
<%= scrivito_details_for 'Height' do %>
|
6
10
|
<%= scrivito_tag(:div, widget, :height) %>
|
7
11
|
<% end %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<section class="parallax scrivito_section_parallax_widget" style="height: <%= widget.height %>; max-height: <%= widget.height %>">
|
2
|
-
<%= scrivito_image_tag widget, :background_image, class: "parallax-image" %>
|
1
|
+
<section class="parallax scrivito_section_parallax_widget parallax_speed_<%= widget.speed %>" style="height: <%= widget.height %>; max-height: <%= widget.height %>">
|
2
|
+
<%= scrivito_image_tag widget, :background_image, class: "parallax-image", data: { parallax_speed: widget.speed } %>
|
3
3
|
<%= scrivito_tag(:div, widget, :section_content, class: 'container') %>
|
4
4
|
</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.17
|
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-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|