Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| yiler-interactivve-buttons-test [2023/01/29 19:22] – yiler.huang | yiler-interactivve-buttons-test [2023/01/29 21:07] (current) – yiler.huang | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | These are the buttons I made for the home page, the interaction only works on computers. | ||
| + | |||
| + | Try hovwering your cursor around the buttons and see what happens. | ||
| + | |||
| ===== Some buttons here ===== | ===== Some buttons here ===== | ||
| Line 6: | Line 10: | ||
| < | < | ||
| < | < | ||
| - | html{ | ||
| - | background-color:# | ||
| | | ||
| width: auto; | width: auto; | ||
| Line 329: | Line 331: | ||
| }).opacity(0) | }).opacity(0) | ||
| } | } | ||
| + | |||
| let titles = { | let titles = { | ||
| - | destressingTitle: | + | destressingTitle: |
| family: ' | family: ' | ||
| size: 19.5 | size: 19.5 | ||
| }), | }), | ||
| - | elderlyTitle: | + | elderlyTitle: |
| family: ' | family: ' | ||
| size: 19.5 | size: 19.5 | ||
| }), | }), | ||
| - | microTitle: microCanvas.text(" | + | microTitle: microCanvas.text(" |
| family: ' | family: ' | ||
| size: 19.5, | size: 19.5, | ||
| leading: ' | leading: ' | ||
| }), | }), | ||
| - | simulationTitle: | + | simulationTitle: |
| size: 19.5, | size: 19.5, | ||
| family: ' | family: ' | ||
| }), | }), | ||
| - | hydraTitle: hydraCanvas.text(" | + | hydraTitle: hydraCanvas.text(" |
| family: ' | family: ' | ||
| size: 19.5, | size: 19.5, | ||
| leading: " | leading: " | ||
| }), | }), | ||
| - | visualTitle: | + | visualTitle: |
| family: ' | family: ' | ||
| size: 19.5, | size: 19.5, | ||
| leading: " | leading: " | ||
| }), | }), | ||
| - | studentsTitle: | + | studentsTitle: |
| family: ' | family: ' | ||
| size: 19.5 | size: 19.5 | ||
| }), | }), | ||
| - | impressionTitle: | + | impressionTitle: |
| family: ' | family: ' | ||
| size: 19.5 | size: 19.5 | ||
| Line 440: | Line 443: | ||
| //last four numbers: title shift x, title shift y, description shift y | //last four numbers: title shift x, title shift y, description shift y | ||
| let destressingButtonObject = new Button(" | let destressingButtonObject = new Button(" | ||
| - | makeButton(destressingCanvas, | + | makeButton(destressingCanvas, |
| let elderlyButtonObject = new Button(" | let elderlyButtonObject = new Button(" | ||
| - | makeButton(elderlyCanvas, | + | makeButton(elderlyCanvas, |
| let microButtonObject = new Button(" | let microButtonObject = new Button(" | ||
| - | makeButton(microCanvas, | + | makeButton(microCanvas, |
| let hydraButtonObject = new Button(" | let hydraButtonObject = new Button(" | ||
| - | makeButton(hydraCanvas, | + | makeButton(hydraCanvas, |
| let visualButtonObject = new Button(" | let visualButtonObject = new Button(" | ||
| - | makeButton(visualCanvas, | + | makeButton(visualCanvas, |
| let simulationButtonObject = new Button(" | let simulationButtonObject = new Button(" | ||
| - | makeButton(simulationCanvas, | + | makeButton(simulationCanvas, |
| let studentsButtonObject = new Button(" | let studentsButtonObject = new Button(" | ||
| - | makeButton(studentsCanvas, | + | makeButton(studentsCanvas, |
| let impressionButtonObject = new Button(" | let impressionButtonObject = new Button(" | ||
| - | makeButton(impressionCanvas, | + | makeButton(impressionCanvas, |
| Line 472: | Line 475: | ||
| } | } | ||
| - | function makeButton(svgCanvas, | + | function makeButton(svgCanvas, |
| let titleRunner; | let titleRunner; | ||
| let textBoxRunner; | let textBoxRunner; | ||
| Line 541: | Line 544: | ||
| }); | }); | ||
| hitBox.on(" | hitBox.on(" | ||
| - | window.location.href = " | + | window.location.href = url; |
| }); | }); | ||
| Line 551: | Line 554: | ||
| }; | }; | ||
| - | function activateDestressingButton() { | ||
| - | let titleRunner; | ||
| - | let textBoxRunner; | ||
| - | let backgroundRunner; | ||
| - | let descriptionRunner; | ||
| - | destressingGroup = destressingButton.group() | ||
| - | let title = destressingButton.text(" | ||
| - | family: ' | ||
| - | size: 19.5 | ||
| - | }) | ||
| - | let description = destressingButton.text(" | ||
| - | family: ' | ||
| - | size: 20 | ||
| - | }).opacity(0); | ||
| - | //make the white box invisible | ||
| - | destressingSvgsObj.background.opacity(0); | ||
| - | //add them into a group so it is easier to move them together | ||
| - | destressingSvgs.forEach(e => { | ||
| - | destressingGroup.add(e) | ||
| - | destressingGroup.add(title) | ||
| - | destressingGroup.add(description) | ||
| - | }); | ||
| - | destressingGroup.size(buttonSize, | ||
| - | destressingGroup.move(0, | ||
| - | destressingGroup.id = " | ||
| - | destressingGroup.node.id = " | ||
| - | console.log(destressingGroup.node) | ||
| - | let hitBox = destressingButton.rect(destressingGroup.width(), | ||
| - | destressingGroup.add(hitBox) | ||
| - | let overAnimaton = true; | ||
| - | let outAnimation = false; | ||
| - | //title position | ||
| - | let titleP = { | ||
| - | x: title.x(), | ||
| - | y: title.y() | ||
| - | }; | ||
| - | // | ||
| - | let descriptionP = { | ||
| - | x: description.x(), | ||
| - | y: description.y() | ||
| - | }; | ||
| - | hitBox.on(" | ||
| - | changeCursor(" | ||
| - | if (overAnimaton) { | ||
| - | // | ||
| - | backgroundRunner = destressingSvgsObj.background.animate(animationDuration).opacity(0.8) | ||
| - | textBoxRunner = destressingSvgsObj.textbox.animate(animationDuration).opacity(0) | ||
| - | titleRunner = title.animate(animationDuration).dmove(-39.5, | ||
| - | size: 10 | ||
| - | }) | ||
| - | descriptionRunner = description.animate(animationDuration).opacity(1).dmove(0, | ||
| - | outAnimation = true; | ||
| - | } | ||
| - | // | ||
| - | }) | ||
| - | hitBox.on(" | ||
| - | changeCursor(" | ||
| - | if (outAnimation) { | ||
| - | // | ||
| - | backgroundRunner = destressingSvgsObj.background.animate(animationDuration).opacity(0) | ||
| - | textBoxRunner = destressingSvgsObj.textbox.animate(animationDuration).opacity(1) | ||
| - | titleRunner = title.animate(animationDuration).move(titleP.x, | ||
| - | size: 5 | ||
| - | }) | ||
| - | descriptionRunner = description.animate(animationDuration).opacity(0).move(descriptionP.x, | ||
| - | overAnimaton = false | ||
| - | outAnimation = false | ||
| - | let setOverAnimationToTrue = setTimeout(function() { | ||
| - | overAnimaton = true | ||
| - | }, 250) | ||
| - | } | ||
| - | // | ||
| - | }); | ||
| - | hitBox.on(" | ||
| - | window.location.href = " | ||
| - | }); | ||
| - | //readFile function by: https:// | ||
| - | |||
| - | // Code based on: Kirill Shumilov | ||
| - | |||
| - | // Everything should be ungrouped. And on the same layer. Object to path. | ||
| - | } | ||
| - | |||
| - | // | ||
| - | // | ||
| - | |||
| - | // | ||
| let buttonsCollection = document.getElementsByClassName(" | let buttonsCollection = document.getElementsByClassName(" | ||
| Line 647: | Line 563: | ||
| let br = document.createElement(" | let br = document.createElement(" | ||
| - | buttonsArray.forEach(i | + | let whereButtonsGo |
| + | |||
| + | whereButtonsGo.appendChild(br) | ||
| + | |||
| + | buttonsArray.forEach(i => whereButtonsGo.appendChild(i)) | ||