-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathmain.js
59 lines (50 loc) · 1.28 KB
/
main.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
$(document.body).append('<div id="blurredContentFrame"><div id="blurredContent"></div></div>');
$('#blurredContentFrame').css({
'width': $('#frostedBk').width(),
'height': $('#frostedBk').height()
});
$('#content').clone().appendTo('#blurredContent');
sizeContent();
positionBlur();
function sizeContent() {
$('#blurredContent').css({
'width': $('#content').width(),
'height': $('#content').height()
});
}
function positionBlur() {
var offset = $('#frostedBk').offset();
$('#blurredContentFrame').css({
'left': offset.left,
'top': offset.top
});
$('#blurredContent').css({
'left': -offset.left,
'top': -offset.top
});
}
var dragging = false;
var startX, startY;
var blockStartX, blockStartY;
$('#frostedBk').mousedown(function(e){
e.preventDefault();
dragging = true;
startX = e.pageX;
startY = e.pageY;
blockStartX = parseInt($('#frostedBk').css('left'));
blockStartY = parseInt($('#frostedBk').css('top'));
});
$('#frostedBk').mouseup(function(e){
e.preventDefault();
dragging = false;
});
$(document).on('mousemove', function(e) {
if (dragging) {
$('#frostedBk').css({
'top': blockStartY + e.pageY - startY,
'left': blockStartX + e.pageX - startX
});
positionBlur();
}
});
$(window).on('resize', sizeContent);