-
Notifications
You must be signed in to change notification settings - Fork 0
/
design.js
123 lines (101 loc) · 2.89 KB
/
design.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**
* Andromeda
*/
var Design = {
goToNextProject: function() {
var route = Cargo.Helper.GetCurrentRoute();
var is_feed_view = !!($('[data-view="Feed"]').length > 0);
if (is_feed_view || route == "Feed" || route == "") {
var nextContainer = Design.findActiveProject().next();
if (nextContainer.length > 0) {
$(".project_container.active").removeClass("active");
nextContainer.addClass("active");
var newPos = nextContainer.offset().top;
Design.doScroll(newPos, newPos - 50, 100);
if(nextContainer.next().length <= 0 && Cargo.Helper.GetTotalPages() > Cargo.API.Config.current_page) {
Cargo.View.Autopaginate.Data.is_updating = true;
Cargo.View.Main.NextPage();
}
}
} else {
Action.Project.Next();
}
},
goToPrevProject: function() {
var route = Cargo.Helper.GetCurrentRoute();
var is_feed_view = !!($('[data-view="Feed"]').length > 0);
if (is_feed_view || route == "Feed" || route == "") {
var prevContainer = Design.findActiveProject().prev();
if (prevContainer.length > 0) {
$(".project_container.active").removeClass("active");
prevContainer.addClass("active");
var newPos = prevContainer.offset().top;
Design.doScroll(newPos, newPos + 50, 100);
}
} else {
Action.Project.Prev();
}
},
findActiveProject: function() {
return $(".project_container:in-viewport");
},
bindHotKeys: function() {
// Shortcut navigation
Cargo.Core.KeyboardShortcut.Remove("J");
Cargo.Core.KeyboardShortcut.Remove("K");
Cargo.Core.KeyboardShortcut.Remove("Left");
Cargo.Core.KeyboardShortcut.Remove("Right");
Cargo.Core.KeyboardShortcut.Add("Left", 37, function() {
Design.goToPrevProject();
return false;
});
Cargo.Core.KeyboardShortcut.Add("Right", 39, function() {
Design.goToNextProject();
return false;
});
Cargo.Core.KeyboardShortcut.Add("J", 74, function() {
Design.goToNextProject();
return false;
});
Cargo.Core.KeyboardShortcut.Add("K", 75, function() {
Design.goToPrevProject();
return false;
});
},
doScroll: function(targetYPos, y, t, callback) {
$({scrollPos: y}).animate({scrollPos: targetYPos}, {
duration: t,
easing: "swing",
step: function() {
window.scrollTo(0, this.scrollPos);
}
});
return false;
}
}
/**
* Events
*/
$(function() {
// Loading animations
Cargo.Core.ReplaceLoadingAnims.init();
Design.bindHotKeys();
});
Cargo.Event.on("project_collection_reset", function() {
if (Cargo.Plugins.hasOwnProperty("elementResizer")) {
setTimeout(function() {
Cargo.Plugins.elementResizer.refresh();
}, 5);
}
});
// Set options for element resizer
Cargo.Event.on("element_resizer_init", function(plugin) {
plugin.setOptions({
adjustElementsToWindowHeight: false,
centerElements: false,
allowInit: Cargo.Model.DisplayOptions.get("resize_images")
});
});
Cargo.Event.on("fullscreen_destroy_hotkeys", function() {
Design.bindHotKeys();
});