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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 60a7151697d264d7e7b7d574b8c29f46a7224819
4
- data.tar.gz: 299c525995c795b85111a209ea43a8f59ac61545
3
+ metadata.gz: 51fbd2e71f117e6c7c4c2bea949c20836795d98f
4
+ data.tar.gz: ab9a2a08e8a690dbd9e07af85dae04accb06206c
5
5
  SHA512:
6
- metadata.gz: abce720f60e09b78f64edec1cd67d94ce9ae7036fa2ef4dbbff63417922d2c7add427038f98a4ca3b1674509ff6c298ed03d155ff4143c40adfb35345b12e26b
7
- data.tar.gz: 172ba07397f5e87df469f2de2e5ab1f1dd81a7efdf3d4a10df3d30dcf1c0379aa24d4096e9f4f3ee04e53f96b76e1d9b39e3f592122379f369cd425a737e50d9
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
- var elems = $(".parallax-image");
9
+ scrivito.on('content', function() {
10
+ var images = $(".parallax-image");
10
11
 
11
- if($('body').width() > 1024) {
12
- set_background_positions(elems);
12
+ if($('body').width() > 1024) {
13
+ set_background_positions(images);
13
14
 
14
- $(window).on('scroll', function(event) {
15
- window.requestAnimationFrame(function(){ set_background_positions(elems); });
16
- });
17
- } else {
18
- set_dimension(elems);
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
- $(window).on('resize', function(event) {
22
- set_dimension(elems);
22
+ $(window).on('resize', function(event) {
23
+ set_dimension(images);
24
+ });
23
25
  });
24
26
  });
25
27
 
26
- function set_dimension(elems) {
28
+ function set_dimension(images) {
27
29
  var height = 0;
28
30
  var container = null;
29
31
 
30
- $.each(elems, function(i, elem) {
31
- container = $(elem).parents('.parallax');
32
- height = $(elem).get(0).clientHeight / 1.3;
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(elems) {
43
- $.each(elems, function(i, elem) {
44
- set_background_position(elem);
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(elem) {
49
- $(elem).css({
50
- '-webkit-transform': calulate_position(elem),
51
- '-ms-transform': calulate_position(elem),
52
- '-o-transform': calulate_position(elem),
53
- '-moz-transform': calulate_position(elem),
54
- 'transform': calulate_position(elem),
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(elem) {
59
- var speed = 0.5;
60
- var value = (caluclate_offset(elem) * speed) + "px";
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(elem) {
65
- return window.pageYOffset - $(elem).offset().top;
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
+ }
@@ -11,6 +11,10 @@
11
11
  height: auto;
12
12
  }
13
13
 
14
+ .scrivito_section_parallax_widget.parallax_speed_fixed .parallax-image {
15
+ position: fixed;
16
+ }
17
+
14
18
  .scrivito_section_video_widget video {
15
19
  width: 100%;
16
20
  display: block;
@@ -2,4 +2,5 @@ class SectionParallaxWidget < Widget
2
2
  attribute :section_content, :widgetlist
3
3
  attribute :background_image, :reference
4
4
  attribute :height, :string
5
+ attribute :speed, :enum, values: ["fixed", "slow", "medium", "fast", "deactivate"], default: "medium"
5
6
  end
@@ -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>
@@ -1,3 +1,3 @@
1
1
  module ScrivitoSectionWidgets
2
- VERSION = "0.0.16"
2
+ VERSION = "0.0.17"
3
3
  end
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.16
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-09 00:00:00.000000000 Z
11
+ date: 2015-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler