Giter Club home page Giter Club logo

Comments (10)

madhusportIT avatar madhusportIT commented on May 30, 2024 1

while i'm using VerticalTimelineElement component .vertical-timeline--animate .vertical-timeline-element-icon.is-hidden { visibility: hidden } this class name is coming and making the section hidden

from react-vertical-timeline.

wilbertcaba avatar wilbertcaba commented on May 30, 2024 1

while i'm using VerticalTimelineElement component .vertical-timeline--animate .vertical-timeline-element-icon.is-hidden { visibility: hidden } this class name is coming and making the section hidden

I think this is the intended functionality/setup, since the purpose is to animate the timeline when it is in view using. I suppose it uses Intersection Observer to change the element to visibility: visible, but it it's not changing it for me as well, so I guess the Intersection Observer is not kicking in to display my <VerticalTimelineElement>'s.

@madhusportIT Did you find a solution to this?

from react-vertical-timeline.

stephane-monnot avatar stephane-monnot commented on May 30, 2024

Could you provide a full example please ?

from react-vertical-timeline.

barbulescualex avatar barbulescualex commented on May 30, 2024
import React from 'react';
import firebase from './Firebase';
import Cookies from 'universal-cookie';
import { VerticalTimeline, VerticalTimelineElement }  from 'react-vertical-timeline-component';
import 'react-vertical-timeline-component/style.min.css';

import Header from './Header';

export default class LoginPage extends React.Component {
    constructor(props){
        super(props);
        this.state = {
            userID: null,
            profileImgUrl: null,
            name: null,
            isDoneLoadingData: false
        }
        this.progressArray = [];
    }

    componentWillMount(){
        let that = this;
        firebase.auth().onAuthStateChanged(function(user) {
            if (user) {
                let userID = firebase.auth().currentUser.uid;
                console.log(userID);
                let cookies = new Cookies();
                let profileImgUrl = (cookies.get('profileImgUrl',{doNotParse:true}));
                let name = (cookies.get('name',{doNotParse:true}));
                that.setState({userID: userID, profileImgUrl: profileImgUrl, name: name},()=>{
                    console.log(this.state);
                    that.fetchProgressData();
                });
            } else {
              console.log('user not signed in');
              his.props.history.replace('/progress');
            }
        });
    }

    fetchProgressData = () => {
        let ref = firebase.database().ref('users/' + this.state.userID + '/progress')
        ref.on('value', (snapshot)=>{
            console.log(snapshot.val())
            snapshot.forEach((childSnapshot)=>{
                console.log(childSnapshot.val());
                this.progressArray.push(childSnapshot.val());
                this.setState({isDoneLoadingData: true});
            })
        });
       
    }

    constructTimeLine = () =>{
        return(
            this.progressArray.map((object,i) => {
                console.log('test')
                return (
                    <VerticalTimelineElement
                    key={i}
                    style={{visibility:'visible', height:'200px'}}
                    iconStyle={{ background: object.color, color: '#fff' }}
                    date={object.date}
                    position='right'
                    >
                        <div>
                            <div style={{display:'flex'}}>
                                {object.imageUrls.map((url,i)=>{
                                    return(
                                        <img key={i} src={url} style={{width:'50px', height:'50px',marginRight:'5px',borderRadius:'3px'}}></img>
                                    )
                                })
                                }
                            </div>
                            <p style={{color:'green'}}>{object.comments}</p>
                        </div>
                    </VerticalTimelineElement>
                );
            })
        )
    }

    render(){
       return(
            <div>
                <Header
                name={this.state.name}
                imgUrl={this.state.profileImgUrl}
                />
                {this.state.isDoneLoadingData&&
                    <VerticalTimeline>
                        {this.constructTimeLine()}
                    </VerticalTimeline> 
                }
            </div>
       )
    }
}

This is the page that gets rendered using react-router. I have barebones styling as I'm building out functionality first, turns out the issue was with react-visibility, I have no clue why it was getting called and hidding all the VerticalTimeLineElements but I have commented it out in your ./dist-es6/VerticalTimeLineElement.js and the timeline is now visible. Although interestingly enough I can't seem to set the position for the elements (they all render on the right).

  _createClass(VerticalTimelineElement, [{
    key: 'onVisibilitySensorChange',
    value: function onVisibilitySensorChange(isVisible) {
      //if (isVisible) {
        this.setState({ visible: true });
      //}
    }
  }, {

from react-vertical-timeline.

stephane-monnot avatar stephane-monnot commented on May 30, 2024

I tried, It works for me.
For the position, if you remove the position prop, it will automatically position to left and right.

image

const constructTimeLine = () =>
  [
    { color: 'red', comments: 'test', date: 'dada' },
    { color: 'blue', comments: 'test 2', date: 'dada' },
  ].map((object, i) => {
    console.log('test');
    return (
      <VerticalTimelineElement
        key={i}
        style={{ visibility: 'visible', height: '200px' }}
        iconStyle={{ background: object.color, color: '#fff' }}
        date={object.date}
      >
        <div>
          <div style={{ display: 'flex' }}>tata</div>
          <p style={{ color: 'green' }}>{object.comments}</p>
        </div>
      </VerticalTimelineElement>
    );
  });

And I use in my render function :

render () {
  return <VerticalTimeline>{constructTimeLine()}</VerticalTimeline>
}

from react-vertical-timeline.

Shubham-luv2code avatar Shubham-luv2code commented on May 30, 2024

I'm working on this mapping the elements of timeline today. It doesn't populate the elements for me.

`getIconClass(val) {
var iconClass = '';
switch (val) {
case 'initialize':
iconClass = "fa fa-3x fa-hourglass-start"
break;
case 'progress':
iconClass = "fa fa-3x fa-caret-square-o-down"
break;
case 'email':
iconClass = "fa fa-3x fa-envelope"
break;
case 'end':
iconClass = "fa fa-3x fa-hourglass-end"
break;
default:
iconClass = "fa fa-3x fa-caret-square-o-down"
break;

    }
    return iconClass;
}

renderTimelineElements() {
    const { apiRes } = this.state;
    apiRes.StaticWorkflowRes.forEach((element, ind) => {
        if (element.reqType === this.props.reqTypeId) {
            element.steps.map((eleMap, ind) => {
                var iconClass = this.getIconClass(eleMap.stepType);
                return (
                <VerticalTimelineElement
                    key={ind}
                    className="vertical-timeline-element"
                    contentStyle={{ background: 'rgb(33, 150, 243)', color: '#fff' }}
                    contentArrowStyle={{ borderRight: '7px solid  rgb(33, 150, 243)' }}
                    date={`Step ${ind + 1}`}
                    iconStyle={{ background: 'rgb(33, 150, 243)', color: '#fff' }}
                    icon={<i className={iconClass}
                        style={{
                            'position': 'absolute',
                            'right': '11px',
                            'top': '10px'
                        }}></i>}
                >
                    <div>
                        <h3 className="vertical-timeline-element-title">{eleMap.titleVal}</h3>
                        <h4 className="vertical-timeline-element-subtitle">{eleMap.subtitleVal}</h4>
                        <p>{eleMap.stepDesc}</p>
                    </div>
                </VerticalTimelineElement>
                )
            })
        }
    });
}
render() {
    return (
        <React.Fragment>
            <VerticalTimeline animate={true}>
                {this.renderTimelineElements()}
            </VerticalTimeline>
        </React.Fragment>
    )
}`

from react-vertical-timeline.

madhusportIT avatar madhusportIT commented on May 30, 2024

Hi @wilbertcaba use visible={true} props inside of the VerticalTimelineElement Element

from react-vertical-timeline.

wilbertcaba avatar wilbertcaba commented on May 30, 2024

Hi @wilbertcaba use visible={true} props inside of the VerticalTimelineElement Element

@madhusportIT Thanks for the tip. That effectively makes the <VerticalTimelineElement> visible, but then I loose the animation once the elements are in view. These animations are enabled by intersectionObserverProps={{ rootMargin: "0px 0px 40px 0px" }} when the <VerticalTimeline> enters the viewport, I guess only when visible={false}.

@stephane-monnot Any thoughts?

from react-vertical-timeline.

madhusportIT avatar madhusportIT commented on May 30, 2024

@wilbertcaba but in my case the animation is working

from react-vertical-timeline.

wilbertcaba avatar wilbertcaba commented on May 30, 2024

@madhusportIT do you have the timeline above the fold?

If the timeline is in the viewport (or above the fold) when the page is loaded, the animation works for me as well. If the timeline is not in the viewport, the animation works as well, but by the time I scroll down to the timeline the animation has already been executed so I don't get to see it.

Anyways, I was using Next.js 14.1.0 and I did some magic tricks to make it work by creating a component for the <VerticalTimelineElement> then importing and using it within <VerticalTimeline>. But, I ended up downgrading to Next.js 13 (not my desired outcome) which also worked for me by using it as intended (as seen in the Docs) without having to use visible={true} props.

from react-vertical-timeline.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.