-
Notifications
You must be signed in to change notification settings - Fork 0
/
mindfulscrolling.html
186 lines (157 loc) · 5.71 KB
/
mindfulscrolling.html
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<!DOCTYPE html>
<!--
Mindful Scrolling by Matthias Pitscher, 2017. www.pitscher.net
Also check www.socialmediameditation.net
This work is part of:
Archiv der Moderne
Sammlung für Architektur, Ingenieurbau, Kunst und Design
Bauhausstraße 7b
99423 Weimar
-->
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="keywords" content="social,media,meditation,mindfulness,contemporary,post-internet">
<meta name="author" content="Matthias Pitscher">
<title>Mindful Scrolling</title>
<link rel="icon" href="ms-favicon.ico" type="image/ico">
<script>
/*********************************************************
This JavaScript section contains all the magic for the
artwork "mindful scrolling" by Matthias Pitscher.
No changes shall be made on the original code without
getting in contact with the artist first. If this is
not possible the code should be changed according
to the comments that explain the general concept.
The code is licensed under GNU GPL and therefore can
be used as free software. As mentioned before,
the artwork belongs to "Archiv der Moderne", who have
the solitary right to exhibit this work.
*********************************************************/
/********************************************************
CONCEPT
White boxes are centered on the screen with a border-
radius of 4px. The background is greyblue (#E9EBEE).
The first box reads "What's on your Mind", which dis-
appears when the user clicks on it.
The second and all additional boxes are underneath with
a gap of 12px.
New boxes with a random height between 100px and 400px
are generated when the user scrolls down.
********************************************************/
var scroll_position = 0; //Current scroll position
var end_scroll_position = 0; //Position when new Divs get created
var ticking = false; //only check for scroll_position, if user is actually scrolling
window.addEventListener('scroll', function(e) {
scroll_position = window.scrollY;
if (!ticking) {
window.requestAnimationFrame(function() {
if (scroll_position >= end_scroll_position) {
var rand = Math.floor((Math.random() * 300) + 100);
var div = document.createElement("div");
div.className = "container";
div.style.height = rand.toString() + 'px';
document.body.appendChild(div);
end_scroll_position += rand;
}
ticking = false;
});
}
ticking = true;
});
/* REMOVE TEXT ON CLICK */
function removeText(e) {
e.innerHTML = "";
}
/***************************************
AUTOMATIC SCROLLING
for exhibition purposes
PRESS A to start scrolling
PRESS S to stop
multiple presses result in faster
scrolling.
***************************************/
window.addEventListener("keydown", function(event) {
if (event.defaultPrevented) {
return; // Do nothing if the event was already processed
}
if (event.key == "A" || event.key == "a") {
pageScroll();
}
if (event.key == "S" || event.key == "s") {
pageScrollStop();
}
})
function pageScroll() {
window.scrollBy(0, 1);
scrolldelay = setTimeout(pageScroll, 30);
}
function pageScrollStop() {
clearTimeout(scrolldelay);
}
</script>
<style>
/************************************
The style copies the theme of the
facebook feed in 2017.
************************************/
html {
/* Correct the line height in all browsers.*/
line-height: 1.15;
/* Prevent adjustments of font size after orientation changes in IE on Windows Phone and in iOS. */
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
body {
margin: 0;
background: #E9EBEE;
}
.container {
display: block;
background: #fff;
max-width: 500px;
height: 400px;
margin: 0 auto;
margin-top: 12px;
border-radius: 4px;
box-shadow: 0px 0px 2px #888888;
}
#first {
height: 70px;
color: #90949C;
padding: 30px;
box-sizing: border-box;
font-family: Helvetica, sans-serif;
}
/* The white container stretches to full width on small screens */
@media only screen and (max-width: 600px) {
.container {
width: 100%;
border-radius: 0px;
}
}
</style>
</head>
<body>
<div class="container" id="first" onclick="removeText(this)"> What's on your mind?</div>
<div class="container" style="height: 128px;"></div>
<div class="container" style="height: 269px;"></div>
<div class="container" style="height: 417px;"></div>
<div class="container" style="height: 212px;"></div>
<div class="container" style="height: 139px;"></div>
<div class="container" style="height: 193px;"></div>
<div class="container" style="height: 351px;"></div>
<div class="container" style="height: 343px;"></div>
<div class="container" style="height: 141px;"></div>
<div class="container" style="height: 149px;"></div>
<div class="container" style="height: 102px;"></div>
<div class="container" style="height: 312px;"></div>
<div class="container" style="height: 495px;"></div>
<div class="container" style="height: 453px;"></div>
<div class="container" style="height: 440px;"></div>
<div class="container" style="height: 353px;"></div>
<div class="container" style="height: 446px;"></div>
<div class="container" style="height: 385px;"></div>
</body>
</html>