I have successfully targeted my hidden class of elements and displayed each element separately using this code:
var x = document.getElementsByClassName("bubble");
var i;
for (i = 0; i < x.length; i++) {
if (x[i].style.display != "block"){
x[i].style.display = "block"
break;}
}
Now I just need to move the entire class up programmatically with javaScript but have gotten stuck
If anyone could take a look at my function and help get this baby working that would be wonderful Thanks!
Connor targeting and moving class javascript.hype.zip (25.0 KB)
You are closer than You think… I removed the “break” and added “px” to the “-200” in the “showBubblesMoveUp” function:
var x = document.getElementsByClassName("bubble");
var i;
for (i = 0; i < x.length; i++) {
if (x[i].style.display != "block"){
x[i].style.display = "block"
x[i].style.top="-200px";
}
}
Thanks for taking a look.
Could you please upload the hype document with your changes?
I tried to follow your suggestions of: removing the “break” and adding “px” to the “-200” in the “showBubblesMoveUp” function but now the elements are not displayed.
Thanks targeting and moving class javascript.hype.zip (25.1 KB)
I did not include the final “curly brace” … } … in the code as there was no top line to match. Sorry for the confusion.
The function written in full this time:
function showBubblesMoveUp(hypeDocument, element, event) {
var x = document.getElementsByClassName("bubble");
var i;
for (i = 0; i < x.length; i++) {
if (x[i].style.display != "block"){
x[i].style.display = "block"
x[i].style.top="-200px";
}
}
}
Apologies for not being more clear… I am trying to move the whole class up incrementally every time the button is pressed. Similar to how each of the bubble elements are shown individually per click. In the end the function would mimic text messages on a user’s phone.
I feel like i need another if statement comparing the class’s current location variable to the new location.
Or appending the bubble class and adding a new child to it, which would in effect move the class up.
Thank you for your assistance , now all I need is for the user to be able to reverse and go back to the previous element which have already been shown.
I have tried re engineering your code with the opposite style selectors:
var bubbleElements = document.getElementsByClassName("bubble");
var thisBubble = ""
for (i = 0; i < bubbleElements.length; i++) {
thisBubble = hypeDocument.getElementById('bubble-'+ (i +1))
if (thisBubble.style.display == "block"){
//thisBubble.style.display != "block"
var elBottom = hypeDocument.getElementProperty(thisBubble, 'bottom')
hypeDocument.setElementProperty(thisBubble, 'bottom', 250 - 10, .5, 'easeinout')
return
} else {
if (thisBubble.style.display =! "block"){
var elTop = hypeDocument.getElementProperty(thisBubble, 'bottom')
hypeDocument.setElementProperty(thisBubble, 'bottom', elBottom - 75, .25, 'easeinout')
}
I need to get a list of hidden elements and show them in a new list, thereby increasing the size of the DOM and using the .scrollToBottom function. Operating similar to a SMS texting system.
Except instead of content arriving from 1 user to another it goes from a hidden list to a new list.
This is what I have so farChatBot ConnorLondon.hype.zip (19.2 KB) using a strategy of setting an entire class “bubble” to hidden and then running a function which:
1st: cycles through the hidden class of bubbles and makes them visible incrementally with a counter.
2nd . Then each element is moved up by resetting its property.
This almost works except when the bubbleBack function runs the order the bubble class can get messed up.
I also know a better way to programmatically achieve my goal is to use the .scrolltoBottom method with 2 lists. But haven’t been able to crack it.
If anyone can give me pointer a to get across the finish line that would be greatly appreciated.
Awesome, thank you for your help, I really appreciate it!
After keeping the bubbles in order, the last thing i need to accomplish (hopefully with your assistance, thanks again!) is to allow the user to easily navigate back and forth from the fist item in the class to the last.
Currently ChatBot MHvCLv2.hype.zip (20.5 KB) if the user taps through the story, bubbleForward(), and then scrolls up (bubbleBack() but then needs to scroll back down again (to the next bubble), it’s too difficult to navigate back down to the last class item.
How would I make it so their next tap would show the next blocked item in the class after scrolling up?
I’m thinking I need to use the .scrollToBottom command??
Hopefully this back sense.
Thanks,
-Connor