pageflow-linkmap-page 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -6
- data/app/assets/javascript/pageflow/linkmap_page/page_type.js +32 -4
- data/app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_pan_zoom.js +2 -2
- data/app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_panorama.js +19 -16
- data/app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_scroll_indicators.js +27 -10
- data/app/helpers/pageflow/linkmap_page/areas_helper.rb +11 -9
- data/app/views/pageflow/linkmap_page/areas/_div.html.erb +1 -1
- data/app/views/pageflow/linkmap_page/page.html.erb +2 -2
- data/lib/pageflow/linkmap_page/version.rb +1 -1
- data/spec/helpers/pageflow/linkmap_page/areas_helper_spec.rb +42 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1a18f3bb77acbad943c0648729e1d748e0c30fb685cbb700514920313a701be
|
4
|
+
data.tar.gz: e5a641ab8fd520414035553dfc1242bfee4dfb35423c2278c1a25d02fa90f183
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a79656eaf85fa16d48c7e30531d4a1907ca1ca0ecdd62d04984b3740506f3e86b865d7a8da41aca3cad85145b32952e3e450acfccf30dc7feb00742c074cc17
|
7
|
+
data.tar.gz: 8c93f349e4f83c4fe915d5ae12de25f1b39281d48dc46d94bca128a91d7b8fb41f37b43f824d47b30ca7829d6aa6891cc551cf0e883aedd7dcce9df48449fb37
|
data/CHANGELOG.md
CHANGED
@@ -1,14 +1,22 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
-
### Version 2.
|
3
|
+
### Version 2.2.0
|
4
4
|
|
5
|
-
2019-
|
5
|
+
2019-03-05
|
6
6
|
|
7
|
-
[Compare changes](https://github.com/codevise/pageflow-linkmap-page/compare/2-
|
7
|
+
[Compare changes](https://github.com/codevise/pageflow-linkmap-page/compare/2-1-stable...v2.2.0)
|
8
8
|
|
9
|
-
-
|
10
|
-
([#
|
9
|
+
- Only show scroll indicators if at least 20% of panorama is hidden
|
10
|
+
([#52](https://github.com/codevise/pageflow-linkmap-page/pull/52))
|
11
|
+
- Improve phone emulation support
|
12
|
+
([#54](https://github.com/codevise/pageflow-linkmap-page/pull/54))
|
13
|
+
- Bug fix: Handle scroller widget margin correctly
|
14
|
+
([#51](https://github.com/codevise/pageflow-linkmap-page/pull/51))
|
15
|
+
- Bug fix: Prevent letter boxes in pan zoom
|
16
|
+
([#50](https://github.com/codevise/pageflow-linkmap-page/pull/50))
|
17
|
+
- Bug fix: Fix hiding linkmap info boxes
|
18
|
+
([#49](https://github.com/codevise/pageflow-linkmap-page/pull/49))
|
11
19
|
|
12
20
|
See
|
13
|
-
[2-
|
21
|
+
[2-1-stable branch](https://github.com/codevise/pageflow-linkmap-page/blob/2-1-stable/CHANGELOG.md)
|
14
22
|
for previous changes.
|
@@ -63,7 +63,9 @@ pageflow.pageType.register('linkmap_page', _.extend({
|
|
63
63
|
|
64
64
|
this.contentAndBackground.linkmapScrollIndicators({
|
65
65
|
disabled: this.isPanZoomEnabled(configuration),
|
66
|
-
scroller: this.scroller
|
66
|
+
scroller: this.scroller,
|
67
|
+
viewport: this.content,
|
68
|
+
innerScrollerElement: pageElement.find('.linkmap')
|
67
69
|
});
|
68
70
|
|
69
71
|
pageElement.find('.hover_video').linkmapHoverVideo({
|
@@ -254,12 +256,23 @@ pageflow.pageType.register('linkmap_page', _.extend({
|
|
254
256
|
|
255
257
|
resize: function(pageElement, configuration) {
|
256
258
|
this.content.linkmapPanorama('refresh');
|
259
|
+
this.contentAndBackground.linkmapScrollIndicators('refresh');
|
257
260
|
this.content.linkmapPanZoom('refresh');
|
258
261
|
this.linkmapAreas.linkmap('refresh');
|
259
262
|
this.mobileInfoBox.linkmapPaginator('refresh');
|
260
263
|
|
261
264
|
this.updateNavigationMode(configuration);
|
262
265
|
this.content.linkmapLookaround('update', this.getMarginScrollingDisabled(configuration));
|
266
|
+
|
267
|
+
this.phoneEmulationChanged(function() {
|
268
|
+
this.content.linkmapPanorama('update',
|
269
|
+
configuration.add_environment,
|
270
|
+
configuration.limit_scrolling,
|
271
|
+
this.getPanoramaStartScrollPosition(configuration),
|
272
|
+
this.phoneEmulation());
|
273
|
+
|
274
|
+
this.content.linkmapPanorama('resetScrollPosition');
|
275
|
+
});
|
263
276
|
},
|
264
277
|
|
265
278
|
prepare: function(pageElement, configuration) {
|
@@ -350,7 +363,7 @@ pageflow.pageType.register('linkmap_page', _.extend({
|
|
350
363
|
this.linkmapAreas.linkmap('updateHoverVideoEnabled', configuration.get('background_type') === 'hover_video');
|
351
364
|
|
352
365
|
this.afterEmbeddedViewsUpdate(function() {
|
353
|
-
var minScaling =
|
366
|
+
var minScaling = this.phoneEmulation();
|
354
367
|
|
355
368
|
this.linkmapAreas.linkmap('option',
|
356
369
|
'colorMapFileId',
|
@@ -368,7 +381,7 @@ pageflow.pageType.register('linkmap_page', _.extend({
|
|
368
381
|
initialPosition: this.getPanoramaStartScrollPosition(configuration.attributes)
|
369
382
|
});
|
370
383
|
|
371
|
-
this.updateScaledOnPhoneFlags(configuration
|
384
|
+
this.updateScaledOnPhoneFlags(configuration,
|
372
385
|
this.content.linkmapPanorama('instance'));
|
373
386
|
|
374
387
|
this.content.linkmapLookaround('update',
|
@@ -381,8 +394,12 @@ pageflow.pageType.register('linkmap_page', _.extend({
|
|
381
394
|
});
|
382
395
|
},
|
383
396
|
|
384
|
-
updateScaledOnPhoneFlags: function(
|
397
|
+
updateScaledOnPhoneFlags: function(configuration, panorama) {
|
398
|
+
var panZoomOnPhone = configuration.get('mobile_panorama_navigation') === 'pan_zoom';
|
399
|
+
var page = configuration.page;
|
400
|
+
|
385
401
|
page.set('scaled_on_portrait_phone',
|
402
|
+
!panZoomOnPhone &&
|
386
403
|
panorama.getPanoramaSize({
|
387
404
|
pageWidth: 360,
|
388
405
|
pageHeight: 640,
|
@@ -390,6 +407,7 @@ pageflow.pageType.register('linkmap_page', _.extend({
|
|
390
407
|
}).scaled);
|
391
408
|
|
392
409
|
page.set('scaled_on_landscape_phone',
|
410
|
+
!panZoomOnPhone &&
|
393
411
|
panorama.getPanoramaSize({
|
394
412
|
pageWidth: 640,
|
395
413
|
pageHeight: 360,
|
@@ -457,6 +475,16 @@ pageflow.pageType.register('linkmap_page', _.extend({
|
|
457
475
|
return !!$('#entry_preview > .emulation_mode_phone').length;
|
458
476
|
},
|
459
477
|
|
478
|
+
phoneEmulationChanged: function(callback) {
|
479
|
+
var phoneEmulation = this.phoneEmulation();
|
480
|
+
|
481
|
+
if (this.lastPhoneEmulation != phoneEmulation) {
|
482
|
+
callback.call(this);
|
483
|
+
}
|
484
|
+
|
485
|
+
this.lastPhoneEmulation = phoneEmulation;
|
486
|
+
},
|
487
|
+
|
460
488
|
playVideo: function(configuration) {
|
461
489
|
var that = this;
|
462
490
|
|
@@ -201,9 +201,9 @@
|
|
201
201
|
var areaHeight = area.height();
|
202
202
|
var areaPosition = area.position();
|
203
203
|
|
204
|
-
var scale = Math.min(2,
|
204
|
+
var scale = Math.max(1, Math.min(2,
|
205
205
|
this.pageWidth / areaWidth,
|
206
|
-
this.pageHeight / areaHeight);
|
206
|
+
this.pageHeight / areaHeight));
|
207
207
|
|
208
208
|
var result = {
|
209
209
|
scale: scale,
|
@@ -114,6 +114,8 @@
|
|
114
114
|
});
|
115
115
|
|
116
116
|
var positionOverlay = function(area) {
|
117
|
+
var viewport = that.element;
|
118
|
+
|
117
119
|
if (area.is('.editing')) {
|
118
120
|
return;
|
119
121
|
}
|
@@ -133,7 +135,7 @@
|
|
133
135
|
}
|
134
136
|
else {
|
135
137
|
var spaceLeftOfArea = area.offset().left;
|
136
|
-
var spaceRightOfArea =
|
138
|
+
var spaceRightOfArea = viewport.width() - area.offset().left - area.outerWidth();
|
137
139
|
|
138
140
|
if(spaceLeftOfArea < spaceRightOfArea || spaceLeftOfArea < that.overlayBox.outerWidth()) {
|
139
141
|
var overlayAlignmentDirection = "right";
|
@@ -163,8 +165,8 @@
|
|
163
165
|
}
|
164
166
|
|
165
167
|
var spaceToBottom = that.panorama.height() - area.position().top;
|
166
|
-
var spaceToViewportBottom =
|
167
|
-
var spaceToViewportTop =
|
168
|
+
var spaceToViewportBottom = viewport.height() - area.offset().top - area.height() / 2;
|
169
|
+
var spaceToViewportTop = viewport.height() - 50;
|
168
170
|
var minMargin = 40;
|
169
171
|
|
170
172
|
if(that.overlayBox.outerHeight() > spaceToBottom) {
|
@@ -210,8 +212,8 @@
|
|
210
212
|
return;
|
211
213
|
}
|
212
214
|
|
213
|
-
var
|
214
|
-
var distanceLimit =
|
215
|
+
var viewport = this.element;
|
216
|
+
var distanceLimit = viewport.width() > viewport.height() ? viewport.height() : viewport.width();
|
215
217
|
var minOpacity = 0.4;
|
216
218
|
activeAreas.each(function() {
|
217
219
|
var distance = calculateDistance($(this), mX, mY);
|
@@ -262,7 +264,7 @@
|
|
262
264
|
|
263
265
|
getScrollArea: function(activeAreas) {
|
264
266
|
var panorama = this.panorama;
|
265
|
-
var
|
267
|
+
var viewport = this.element;
|
266
268
|
var startScrollPosition = this.startScrollPosition;
|
267
269
|
var scrollArea;
|
268
270
|
|
@@ -283,10 +285,10 @@
|
|
283
285
|
scrollArea.right = scrollArea.right < el.position().left + el.width() ? el.position().left + el.width() : scrollArea.right;
|
284
286
|
});
|
285
287
|
|
286
|
-
scrollArea.top = Math.max(0, scrollArea.top -
|
287
|
-
scrollArea.left = Math.max(0, scrollArea.left -
|
288
|
-
scrollArea.bottom = Math.min(panorama.height(), scrollArea.bottom +
|
289
|
-
scrollArea.right = Math.min(panorama.width(), scrollArea.right +
|
288
|
+
scrollArea.top = Math.max(0, scrollArea.top - viewport.height() * this.scrollHoverMargin);
|
289
|
+
scrollArea.left = Math.max(0, scrollArea.left - viewport.width() * this.scrollHoverMargin);
|
290
|
+
scrollArea.bottom = Math.min(panorama.height(), scrollArea.bottom + viewport.height() * this.scrollHoverMargin);
|
291
|
+
scrollArea.right = Math.min(panorama.width(), scrollArea.right + viewport.width() * this.scrollHoverMargin);
|
290
292
|
}
|
291
293
|
else {
|
292
294
|
scrollArea = {
|
@@ -316,12 +318,13 @@
|
|
316
318
|
|
317
319
|
this.keepingScrollPosition(function() {
|
318
320
|
var pageElement = this.options.page;
|
321
|
+
var viewport = this.element;
|
319
322
|
|
320
323
|
this.panorama = this.options.panorama();
|
321
324
|
|
322
325
|
this.panoramaSize = this.getPanoramaSize({
|
323
|
-
pageWidth:
|
324
|
-
pageHeight:
|
326
|
+
pageWidth: viewport.width(),
|
327
|
+
pageHeight: viewport.height(),
|
325
328
|
|
326
329
|
minScaling: this.minScaling
|
327
330
|
});
|
@@ -340,14 +343,14 @@
|
|
340
343
|
this.innerScrollerElement.width(this.scrollArea.right - this.scrollArea.left);
|
341
344
|
this.innerScrollerElement.height(this.scrollArea.bottom - this.scrollArea.top);
|
342
345
|
|
343
|
-
var centerX = Math.max(0, (
|
344
|
-
var centerY = Math.max(0, (
|
346
|
+
var centerX = Math.max(0, (viewport.width() - (this.scrollArea.right - this.scrollArea.left)) / 2);
|
347
|
+
var centerY = Math.max(0, (viewport.height() - (this.scrollArea.bottom - this.scrollArea.top)) / 2);
|
345
348
|
|
346
349
|
var translateX = this.scrollArea.left - centerX;
|
347
350
|
var translateY = this.scrollArea.top - centerY;
|
348
351
|
|
349
|
-
var maxTranslateX = this.panoramaSize.width -
|
350
|
-
var maxTranslateY = this.panoramaSize.height -
|
352
|
+
var maxTranslateX = this.panoramaSize.width - viewport.width();
|
353
|
+
var maxTranslateY = this.panoramaSize.height - viewport.height();
|
351
354
|
|
352
355
|
this.panoramaWrapper.css({
|
353
356
|
left: -Math.min(maxTranslateX, Math.max(0, translateX)) +'px',
|
@@ -1,27 +1,44 @@
|
|
1
1
|
(function($) {
|
2
|
+
// Only show scroll indicators if at least 20% of the panorama is
|
3
|
+
// outside of the viewport.
|
4
|
+
var minOverflowFraction = 1.2;
|
5
|
+
|
6
|
+
// Ensure scroll indicators are already hidden when the scroller
|
7
|
+
// decelerates while approaching the max scroll position.
|
2
8
|
var margin = 40;
|
3
9
|
|
4
10
|
$.widget('pageflow.linkmapScrollIndicators', {
|
5
11
|
_create: function() {
|
6
|
-
var element = this.element;
|
7
12
|
var scroller = this.options.scroller;
|
8
13
|
|
9
14
|
this.arrows = this.element.find('.linkmap-arrow');
|
10
15
|
|
11
|
-
scroller.onScroll(
|
12
|
-
scroller.onScrollEnd(
|
13
|
-
|
16
|
+
scroller.onScroll(_.bind(this.refresh, this));
|
17
|
+
scroller.onScrollEnd(_.bind(this.refresh, this));
|
18
|
+
this.refresh();
|
14
19
|
|
15
20
|
if (this.options.disabled) {
|
16
21
|
this.disable();
|
17
22
|
}
|
23
|
+
},
|
18
24
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
+
refresh: function() {
|
26
|
+
var element = this.element;
|
27
|
+
var scroller = this.options.scroller;
|
28
|
+
var viewport = this.options.viewport;
|
29
|
+
var innerScrollerElement = this.options.innerScrollerElement;
|
30
|
+
|
31
|
+
var showH = innerScrollerElement.width() / viewport.width() > minOverflowFraction;
|
32
|
+
var showV = innerScrollerElement.height() / viewport.height() > minOverflowFraction;
|
33
|
+
|
34
|
+
element.toggleClass('can_scroll_left',
|
35
|
+
showH && Math.ceil(scroller.positionX()) < - margin);
|
36
|
+
element.toggleClass('can_scroll_right',
|
37
|
+
showH && Math.floor(scroller.positionX()) > scroller.maxX() + margin);
|
38
|
+
element.toggleClass('can_scroll_up',
|
39
|
+
showV && Math.ceil(scroller.positionY()) < - margin);
|
40
|
+
element.toggleClass('can_scroll_down',
|
41
|
+
showV && Math.floor(scroller.positionY()) > scroller.maxY() + margin);
|
25
42
|
},
|
26
43
|
|
27
44
|
disable: function() {
|
@@ -3,6 +3,17 @@ module Pageflow
|
|
3
3
|
module AreasHelper
|
4
4
|
include BackgroundImageHelper
|
5
5
|
|
6
|
+
def linkmap_content_and_background_css_classes(configuration)
|
7
|
+
hide_overlay_boxes =
|
8
|
+
configuration['mobile_panorama_navigation'] == 'pan_zoom' &&
|
9
|
+
configuration['hide_linkmap_overlay_boxes']
|
10
|
+
|
11
|
+
[
|
12
|
+
'content_and_background linkmap_page unplayed',
|
13
|
+
hide_overlay_boxes ? 'hide_overlay_boxes' : nil
|
14
|
+
].compact.join(' ')
|
15
|
+
end
|
16
|
+
|
6
17
|
def linkmap_areas_div(entry, configuration)
|
7
18
|
color_map_file =
|
8
19
|
ColorMapFile.find_by_id(configuration['linkmap_color_map_file_id'])
|
@@ -11,21 +22,12 @@ module Pageflow
|
|
11
22
|
masked_visited_image_file =
|
12
23
|
MaskedImageFile.find_by_id(configuration['linkmap_masked_visited_image_id'])
|
13
24
|
|
14
|
-
|
15
|
-
hide_overlay_boxes =
|
16
|
-
configuration['mobile_panorama_navigation'] == 'pan_zoom' &&
|
17
|
-
configuration['hide_linkmap_overlay_boxes']
|
18
|
-
|
19
25
|
render('pageflow/linkmap_page/areas/div',
|
20
26
|
entry: entry,
|
21
27
|
configuration: configuration,
|
22
28
|
color_map_file: color_map_file,
|
23
29
|
masked_hover_image_file: masked_hover_image_file,
|
24
30
|
masked_visited_image_file: masked_visited_image_file,
|
25
|
-
css_classes: [
|
26
|
-
'linkmap_areas',
|
27
|
-
hide_overlay_boxes ? 'hide_overlay_boxes' : nil
|
28
|
-
].compact.join(' '),
|
29
31
|
data_attributes: {
|
30
32
|
color_map_file_id: configuration['color_map_file_id']
|
31
33
|
})
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= content_tag(:div, class:
|
1
|
+
<%= content_tag(:div, class: 'linkmap_areas', data: data_attributes) do %>
|
2
2
|
<% (configuration['linkmap_areas'].presence || []).each_with_index do |attributes, index| %>
|
3
3
|
<%= linkmap_area(entry, attributes, index, configuration['background_type']) do %>
|
4
4
|
<%= linkmap_area_background_image_div('visited',
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<div class="blackLayer"></div>
|
2
|
-
|
2
|
+
<%= content_tag(:div, class: linkmap_content_and_background_css_classes(configuration)) do %>
|
3
3
|
<div class="backgroundArea">
|
4
4
|
<%= background_image_div(configuration, 'fixed_background_image', class: 'fixed_background') %>
|
5
5
|
<div class="scroller">
|
@@ -97,4 +97,4 @@
|
|
97
97
|
</div>
|
98
98
|
</div>
|
99
99
|
</div>
|
100
|
-
|
100
|
+
<% end %>
|
@@ -3,6 +3,48 @@ require 'spec_helper'
|
|
3
3
|
module Pageflow
|
4
4
|
module LinkmapPage
|
5
5
|
describe AreasHelper do
|
6
|
+
describe '#linkmap_content_and_background_css_classes' do
|
7
|
+
it 'contains default css classes' do
|
8
|
+
classes = helper.linkmap_content_and_background_css_classes({}).split(' ')
|
9
|
+
|
10
|
+
expect(classes).to include('content_and_background')
|
11
|
+
expect(classes).to include('linkmap_page')
|
12
|
+
expect(classes).to include('unplayed')
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'contains hide_overlay_boxes if option is set and pan zoom is active' do
|
16
|
+
configuration = {
|
17
|
+
'mobile_panorama_navigation' => 'pan_zoom',
|
18
|
+
'hide_linkmap_overlay_boxes'=> true
|
19
|
+
}
|
20
|
+
|
21
|
+
classes = helper.linkmap_content_and_background_css_classes(configuration).split(' ')
|
22
|
+
|
23
|
+
expect(classes).to include('hide_overlay_boxes')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'does not contain hide_overlay_boxes if option is not set even if pan zoom is active' do
|
27
|
+
configuration = {
|
28
|
+
'mobile_panorama_navigation' => 'pan_zoom',
|
29
|
+
'hide_linkmap_overlay_boxes'=> false
|
30
|
+
}
|
31
|
+
|
32
|
+
classes = helper.linkmap_content_and_background_css_classes(configuration).split(' ')
|
33
|
+
|
34
|
+
expect(classes).not_to include('hide_overlay_boxes')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'does not contain hide_overlay_boxes if option is set even but pan zoom is not active' do
|
38
|
+
configuration = {
|
39
|
+
'hide_linkmap_overlay_boxes'=> true
|
40
|
+
}
|
41
|
+
|
42
|
+
classes = helper.linkmap_content_and_background_css_classes(configuration).split(' ')
|
43
|
+
|
44
|
+
expect(classes).not_to include('hide_overlay_boxes')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
6
48
|
describe '#linkmap_area_divs' do
|
7
49
|
it 'renders div with attribute name as class' do
|
8
50
|
entry = create(:entry)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pageflow-linkmap-page
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Codevise Solutions Ltd.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pageflow
|
@@ -351,7 +351,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
351
351
|
version: '0'
|
352
352
|
requirements: []
|
353
353
|
rubyforge_project:
|
354
|
-
rubygems_version: 2.7.
|
354
|
+
rubygems_version: 2.7.5
|
355
355
|
signing_key:
|
356
356
|
specification_version: 4
|
357
357
|
summary: Pageflow page type for a page that contains customizable link areas
|