Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript [Solved] Rudimentary animation – showing more content (sliding movement)

  • This topic is empty.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #149497
    Mag
    Participant

    Hi, I’m really beginner in the subject :( Can anyone help me out here? http://jsfiddle.net/f8zqg/179/

    What I’m trying to achieve is showing and hiding div with “lorem ipsum” content.

    I’ve tried some things from: http://api.jquery.com/animate/ but to no avail.

    Thanks!

    #149501
    Paulie_D
    Member

    What precisely are you trying to do?

    You may be trying to replicate an already existing widget functionality.

    #149506
    Mag
    Participant
    1. checking how much text came from cms – if detailDescription is higher than 40px then I’m showing “show more”.
    2. clicking “show more” should slide detailDescription down – here’s my problem with function animate or slideDown
    3. show more should change into “show less”
    4. clicking on show less should slide detailDescription up and so on :)
    #149509
    Paulie_D
    Member

    Hmmm…well there’s two different functions in there.

    Sliding the div and changing the span text…not that you can’t chain them.

    My JS/JQ skills are minimal but I’ll have a think.

    #149510
    Mag
    Participant

    And my problem is: I don’t know what I’m doing wrong but I can’t achieve smooth animation of detailDescription..

    #149511
    Mag
    Participant

    Yeah, changing text is the other problem ;)

    #149512
    Paulie_D
    Member

    Animating to Auto is an issue so a plug-in may be required.

    See the linked article and links within that.

    https://css-tricks.com/css-animate-fromto-auto/

    #149514
    Paulie_D
    Member

    As for swapping out the text see: http://api.jquery.com/html/

    #149575
    Mag
    Participant

    I used:
    .append(“.showMoreText::after{ content:’show more’ }”)
    to change text… But I don’t know if its the best js solution.. :(

    Paulie_D – the thing is I didn’t want to use css transitions – cause I didn’t know the height of the div. I wonder why pure jquery didin’t work..

    #149578
    Paulie_D
    Member

    append(“.showMoreText::after{ content:’show more’ }”)
    to change text… But I don’t know if its the best js solution..

    No, it’s probably not.

    Jquery can grab the actual text and swap it out for other text…see the link I gave.

    As for the animation, pure JQuery is just a large helping hand…it’s not set up to do everything out of the box, that’s why people make plug-ins (which is just more javascript) to help it along with specific functions.

    #149826
    Mag
    Participant

    Thanks for the help :)

Viewing 11 posts - 1 through 11 (of 11 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.