Skip to content

Commit e0f0468

Browse files
committed
fix bug
1 parent c5b005a commit e0f0468

File tree

2 files changed

+56
-30
lines changed

2 files changed

+56
-30
lines changed

css/main.css

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,6 @@ body {
251251
pointer-events: none;
252252
}
253253

254-
#main01 footer {
255-
position: absolute;
256-
bottom: 2%;
257-
left: 0;
258-
width: 100%;
259-
text-align: center;
260-
}
261-
262254
#main01 svg {
263255
width: 100%;
264256
}
@@ -298,13 +290,28 @@ body {
298290
border-radius: 50%;
299291
}
300292

301-
.monster-btn {
293+
#main01 footer {
294+
position: absolute;
295+
bottom: 2%;
296+
left: 0;
297+
width: 100%;
298+
text-align: center;
299+
}
300+
301+
#main01 footer .monster-btn {
302302
display: inline-block;
303303
width: 22%;
304304
max-width: 20vh;
305305
margin: 0.5%;
306306
z-index: 2;
307-
-webkit-user-select: none;
307+
vertical-align: middle;
308+
}
309+
#main01 footer .monster-btn svg{
310+
transition:.3s;
311+
background:none;
312+
}
313+
#main01 footer .monster-btn.click svg{
314+
width:90%;
308315
}
309316

310317
/* main02 */
@@ -324,10 +331,10 @@ body {
324331

325332
#main02 .btn {
326333
display: inline-block;
327-
width: 40%;
328-
height: 16%;
329-
border: 3px solid #ccc;
330-
margin: 5px 3px;
334+
width: 38%;
335+
height: 14%;
336+
box-shadow:inset #ccc 0 0 0 0, #ccc 0 0 0 3px;
337+
margin: 7px 5px;
331338
border-radius: 10px;
332339
background: rgba(255, 255, 255, .1);
333340
color: #fff;
@@ -336,8 +343,9 @@ body {
336343
transition:.3s;
337344
}
338345

339-
#main02 .btn.touched {
346+
#main02 .btn.click {
340347
background: rgba(255, 255, 255, .4);
348+
box-shadow:inset #ccc 0 0 0 3px, #ccc 0 0 0 0;
341349
}
342350

343351
#main02 .btn::before {
@@ -352,6 +360,11 @@ body {
352360
display: inline-block;
353361
vertical-align: middle;
354362
font-size: 1.5rem;
363+
transition:.3s;
364+
}
365+
366+
#main02 .btn.click span {
367+
font-size: 1.4rem;
355368
}
356369

357370
/* popup */

js/main.js

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
//https://webbit.webduino.io/blockly/?demo=default#EqdrNJvwYzQy6
1+
/*
2+
* demo site: https://webbit.webduino.io/blockly/?demo=default#EqdrNJvwYzQy6
3+
*/
4+
25
~async function () {
3-
// 凱比定位
6+
// 載入 js 之後顯示所有元件
47
const content = document.querySelector('.content');
58
content.classList.remove('loading');
9+
10+
// 凱比機器人和中間的圓形 logo 定位
611
const kebbi = document.getElementById('svgKebbi');
712
const circle = document.querySelector('.circle');
813
const ww = content.offsetWidth;
@@ -52,6 +57,7 @@
5257
};
5358

5459
const urlOrigin = location.origin;
60+
const urlPath = location.pathname;
5561
const urlHash = location.hash.replace('#', '');
5662
const config = {
5763
databaseURL: "https://webbit-remote.firebaseio.com/"
@@ -70,8 +76,9 @@
7076
saveBtn.addEventListener('click', async function () {
7177
let write = await database.ref('/').push(list);
7278
popup.classList.add('show');
73-
saveUrl.innerText = urlOrigin + '/#' + write.key;
74-
window.history.pushState({}, 0, urlOrigin + '#' + write.key);
79+
let url = `${urlOrigin}${urlPath}#${write.key}`;
80+
saveUrl.innerText = url;
81+
window.history.pushState({}, 0, url);
7582
document.getSelection().removeAllRanges();
7683
});
7784

@@ -168,7 +175,7 @@
168175
await webduinoBroadcastor.connect();
169176
}
170177
// 發送 mqtt 訊號
171-
const mqtt = async function (topic, msg) {
178+
const mqttPush = async function (topic, msg) {
172179
if (topic == list.topic1) {
173180
webduinoBroadcastor.send({
174181
topic: topic,
@@ -199,7 +206,11 @@
199206
monsterBtn.forEach(e => {
200207
let self = e;
201208
self.addEventListener('click', () => {
202-
mqtt(list.topic1, list[self.id]);
209+
mqttPush(list.topic1, list[self.id]);
210+
self.classList.add('click');
211+
setTimeout(()=>{
212+
self.classList.remove('click');
213+
},100);
203214
});
204215
});
205216

@@ -208,12 +219,14 @@
208219
let self = e;
209220
let msg = self.getAttribute('msg');
210221
self.addEventListener('click', () => {
211-
mqtt(list.topic1, list[msg]);
222+
mqttPush(list.topic1, list[msg]);
223+
self.classList.add('click');
224+
setTimeout(()=>{
225+
self.classList.remove('click');
226+
},100);
212227
});
213228
});
214229

215-
216-
217230
let send = {
218231
center: false,
219232
top: false,
@@ -258,28 +271,28 @@
258271
if (kx < ww * 0.2) {
259272
if (!send.left) {
260273
sendCheck('left');
261-
mqtt(list.topic1, list.kebbiLeft);
274+
mqttPush(list.topic1, list.kebbiLeft);
262275
}
263276
} else if (kx > ww * 0.5) {
264277
if (!send.right) {
265278
sendCheck('right');
266-
mqtt(list.topic1, list.kebbiRight);
279+
mqttPush(list.topic1, list.kebbiRight);
267280
}
268281
} else {
269282
if (ky < wh * 0.2) {
270283
if (!send.top) {
271284
sendCheck('top');
272-
mqtt(list.topic1, list.kebbiTop);
285+
mqttPush(list.topic1, list.kebbiTop);
273286
}
274287
} else if (ky > wh * 0.4) {
275288
if (!send.bottom) {
276289
sendCheck('bottom');
277-
mqtt(list.topic1, list.kebbiBottom);
290+
mqttPush(list.topic1, list.kebbiBottom);
278291
}
279292
} else {
280293
if (!send.center) {
281294
sendCheck('center');
282-
mqtt(list.topic1, list.kebbiReset);
295+
mqttPush(list.topic1, list.kebbiReset);
283296
}
284297
}
285298
}
@@ -303,7 +316,7 @@
303316
function reset() {
304317
if (send.top || send.bottom || send.left || send.right) {
305318
console.log('reset');
306-
mqtt(list.topic1, list.kebbiReset);
319+
mqttPush(list.topic1, list.kebbiReset);
307320
}
308321
sendCheck();
309322
drag = false;

0 commit comments

Comments
 (0)