<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jay Vijay Modi</title>
    <description>The latest articles on DEV Community by Jay Vijay Modi (@jayvijaymodi1).</description>
    <link>https://dev.to/jayvijaymodi1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F675602%2F11e30ddf-4a2d-4cfb-9558-916607b5e536.png</url>
      <title>DEV Community: Jay Vijay Modi</title>
      <link>https://dev.to/jayvijaymodi1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jayvijaymodi1"/>
    <language>en</language>
    <item>
      <title>Smooth parallax effect not responding properly</title>
      <dc:creator>Jay Vijay Modi</dc:creator>
      <pubDate>Sat, 21 Aug 2021 16:37:00 +0000</pubDate>
      <link>https://dev.to/jayvijaymodi1/smooth-parallax-effect-not-responding-properly-371</link>
      <guid>https://dev.to/jayvijaymodi1/smooth-parallax-effect-not-responding-properly-371</guid>
      <description>&lt;p&gt;Currently what I'm trying to achieve is this, where 1 image moves from left to right as the user scrolls down creating a parallax effect:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gNytAYE6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bsapah0q3g78tckx91vv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gNytAYE6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bsapah0q3g78tckx91vv.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Normally with DOM I would use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let image = document.getElementById("image");

window.addEventListener('scroll', function() {
  let value = window.scrollY;
  image.style.marginRight = value * 4 + 'px';
  image.style.marginTop = value * 1.5 + 'px';
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But currently I'm trying to replicate this effect in React using setState, but the image doesn't move along with mouse scroll wheel and the layout does not seem right:&lt;/p&gt;

&lt;p&gt;CodeSandBox: &lt;a href="https://codesandbox.io/s/modest-hill-2wuko?file=/src/App.tsx"&gt;https://codesandbox.io/s/modest-hill-2wuko?file=/src/App.tsx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const [leftScroll,setLeftScroll] = useState(false);
const [topScroll,setTopScroll] = useState(false);
const [textScroll, setTextScroll] = useState(false);

  useEffect(function onFirstMount() {
    const changeBackground = () =&amp;gt; {
      let value =  window.scrollY;
      console.log(window.scrollY);

      if(value&amp;gt;0 &amp;amp;&amp;amp; value&amp;lt;200){
        setLeftScroll(true)
        setTopScroll(true)
        setTextScroll(true);
      }else{
        setLeftScroll(false)
        setTopScroll(false)
        setTextScroll(false);
      }
    }

    window.addEventListener('scroll', changeBackground);

    return null;
  }, []);
  return (
    &amp;lt;div className="background"&amp;gt;
     &amp;lt;div style={{backgroundColor:"#0E2043",padding:"50px",height:"1000px",display:"flex",justifyContent:"center"}}&amp;gt;
      &amp;lt;div style={{color:"#fff",textAlign:"center",fontSize:"100px",fontFamily:"Roboto", display:"flex",justifyContent:"center"}}&amp;gt;Vanuatu&amp;lt;/div&amp;gt;
      &amp;lt;img className="image"
              style={{marginRight:leftScroll ? '300px' : '0px',transition:"2s",marginTop:topScroll ? "300px" : "0px"}}
              src="https://cdn.britannica.com/87/122087-050-1C269E8D/Cover-passport.jpg"
            /&amp;gt;
       &amp;lt;div
          className="text"
          style={{
            marginTop: textScroll ? "300px" : "800px",
            transition: "4s",
            marginLeft: "120px"
          }}
        &amp;gt;
          Minimum Investment
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So is there an easier way to do this or can I implement those DOM functions in my React project and still have a parallax like effect?&lt;/p&gt;

</description>
      <category>help</category>
    </item>
    <item>
      <title>Using useState to edit the style of a Component in React Native</title>
      <dc:creator>Jay Vijay Modi</dc:creator>
      <pubDate>Sun, 08 Aug 2021 12:23:48 +0000</pubDate>
      <link>https://dev.to/jayvijaymodi1/using-usestate-to-edit-the-style-of-a-component-in-react-native-3n2a</link>
      <guid>https://dev.to/jayvijaymodi1/using-usestate-to-edit-the-style-of-a-component-in-react-native-3n2a</guid>
      <description>&lt;p&gt;I am new to using state management and was finding difficulty editing styles of a component using useState. Currently I have a swiper component that holds my main images and below that I have a thumbnail gallery for each of those images with a &lt;code&gt;borderWidth:1&lt;/code&gt;. What I want is that only the border for the current slide should be active while the others show no borderWidth. Currently my display looks like this where all the thumbnails have a border:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default function App() { 

    const [activeBorder, setActiveBorder] = useState();
      const [activeIndex, setActiveIndex] = useState();
      const fishMapping = ["Fish Azure", "Fish Salmon", "Fish Another"];
      const onIndexChanged = (index) =&amp;gt; setActiveIndex(index);

      return (
        &amp;lt;View style={{ flex: 1 }}&amp;gt;
          &amp;lt;ImageBackground
            style={globalStyles.backgroundImage}
            source={require('./resource/images/bg1080.jpeg')}
          &amp;gt;
          &amp;lt;Fish onIndexChanged={onIndexChanged}/&amp;gt;
          &amp;lt;BottomImages /&amp;gt;
          { activeIndex &amp;amp;&amp;amp; &amp;lt;Text&amp;gt;`Fish` ${fishMapping[activeIndex]}&amp;lt;/Text&amp;gt; }
          &amp;lt;/ImageBackground&amp;gt;
        &amp;lt;/View&amp;gt;
      );
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And for the thumbnails below this is my code:&lt;br&gt;
BottomImages.js:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default class BottomImages extends Component { 

    state = {
        columns: 3,
      };

      render() {
        const { columns } = this.state;
        return (
          &amp;lt;View style={styles.container}&amp;gt;
            &amp;lt;FlatList
              numColumns={columns}
              data={[
                require('../resource/images/AzureDamsel.png'),
                require('../resource/images/BicolourAngelfish.png'),
                require('../resource/images/ClownTriggerfish.png'),
              ]}
              renderItem={({ item }) =&amp;gt; {
                return (
                  &amp;lt;ListItem
                    itemWidth={(ITEM_WIDTH - 10 * columns) / columns}
                    image={item}
                  /&amp;gt;
                );
              }}
              keyExtractor={(index) =&amp;gt; {
                return index;
              }}
            /&amp;gt;
          &amp;lt;/View&amp;gt;
        );
      }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ListItem.js which holds my thumbnail images as well as the borderbox for the images:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const ListItem = (props) =&amp;gt; {  

      const { itemWidth } = props;

      return (
        &amp;lt;TouchableWithoutFeedback&amp;gt;
          &amp;lt;Animated.View
            style={{
              margin: 5,
            }}&amp;gt;
            &amp;lt;Image
              style={{
                width: itemWidth,
                height: 50,
                borderWidth: 1,
                borderColor: '#000',
              }}
              source={props.image}&amp;gt;&amp;lt;/Image&amp;gt;
          &amp;lt;/Animated.View&amp;gt;
        &amp;lt;/TouchableWithoutFeedback&amp;gt;
      );
    };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's a link to the snack just in case: &lt;a href="https://snack.expo.dev/@jay_m/paranoid-carrot"&gt;Sandbox&lt;/a&gt;&lt;/p&gt;

</description>
      <category>help</category>
    </item>
  </channel>
</rss>
