SVG Animation: Object along a path on a scroll, speed up certain sections

So I have used the solution posted here to make a little rocket follow the specific svg path I created on scroll. This so far works great. My svg path has a looping in it and other sections in which the rocket moves sideways or even up. This obviously leads to the rocket at one point moving out of view because it follows the path on scroll speed even when moving up.

Now I want to move the rocket faster when the rocket moves upwards (or possibly even a bit when it moves sideways). I can’t seem to figure it out. Under this link you will find my code (only this file is important). The code is in svelte but that shouldn’t matter.

My idea includes checking if the angle variable is negative, which means rocket moving upwards, and then changing the dist variable by a certain amount. This just leads to the rocket flickering around. I guess I should change something when angle is negative, but I cannot figure out what.

Vue draggable no drop animation

I have a kanban board that displays issues in a project made up of three lists, Open, In Progress, and Completed.
I am using vue draggable in order to drag and drop issues between the three lists.
I fetch the issues from an api call using axios and I also update each issues status(i.e Open, In Progress, Closed) with a post request as well.
The issue is that when I drag an issue, lets say from Open and drop it in In Progress, the issue returns to the Open column in the kanban board. I have to refresh the page for the issue to move to the In Progress column. This means that the update request is working.
But how can I make the issue move without refreshing the page?

KanBanBoard.vue

<template>
  <v-container>
    <v-row wrap>
      <v-col xl="4" lg="4" md="4" sm="4" xs="12">
        <v-card>
          <v-card-title class="blue lighten-3">
            <span class="white--text">Open</span>
          </v-card-title>
          <v-divider horizontal></v-divider>
          <v-card-text class="blue lighten-3">
            <draggable class="list-group kanban-column" :list="Open" group="tasks" :move="onDrop">
              <v-card
                class="#f4f5fa"
                style="height:auto; margin-top:10px"
                v-for="issue in Open"
                :key="issue"
                align-center
                elevation="3"
              >
                <v-card-text>
                  <v-row dense style="width:auto">
                    <router-link
                      class="d-flex align-center text-decoration-none grey--text"
                      style="font-size:18px;"
                      :to="{ name: 'IssuePage', params: { id: issue.id, issue } }"
                    >
                      {{ issue.title }}
                    </router-link>
                  </v-row>

                  <v-row dense>
                    <v-col>
                      <v-chip
                        class="ma-2"
                        color="red"
                        outlined
                        style="position:relative; right:10px;top:10px; height:min-content"
                      >
                        {{ issue.issueSeverity }}
                      </v-chip>
                    </v-col>
                    <v-col>
                      <v-chip
                        class="ma-2"
                        color="green"
                        outlined
                        style="position:relative; right:83px; top:10px;height:min-content"
                      >
                        {{ issue.issueType }}
                      </v-chip>
                    </v-col>
                  </v-row>
                </v-card-text>
              </v-card>
            </draggable>
          </v-card-text>
        </v-card>
      </v-col>

      <v-col xl="4" lg="4" md="4" sm="4" xs="12">
        <v-card>
          <v-card-title class="light-green lighten-3">
            <span class="white--text">In Progress</span>
          </v-card-title>
          <v-divider horizontal></v-divider>
          <v-card-text class="light-green lighten-3">
            <draggable class="list-group kanban-column" :list="InProgress" group="tasks" :move="onDrop">
              <v-card
                class="#f4f5fa"
                style="height:auto; margin-top:10px"
                v-for="issue in InProgress"
                :key="issue"
                align-center
                elevation="3"
              >
                <v-card-text>
                  <v-row dense style="width:auto">
                    <router-link
                      class="d-flex align-center text-decoration-none grey--text"
                      style="font-size:18px;"
                      :to="{ name: 'IssuePage', params: { id: issue.id, issue } }"
                    >
                      {{ issue.title }}
                    </router-link>
                  </v-row>

                  <v-row>
                    <v-col>
                      <v-chip
                        class="ma-2"
                        color="red"
                        outlined
                        style="position:relative; right:10px;top:10px; height:min-content"
                      >
                        {{ issue.issueSeverity }}
                      </v-chip>
                    </v-col>

                    <v-col>
                      <v-chip
                        class="ma-2"
                        color="green"
                        outlined
                        style="position:relative; right:83px; top:10px;height:min-content"
                      >
                        {{ issue.issueType }}
                      </v-chip>
                    </v-col>
                  </v-row>
                </v-card-text>
              </v-card>
            </draggable>
          </v-card-text>
        </v-card>
      </v-col>

      <v-col xl="4" lg="4" md="4" sm="4" xs="12">
        <v-card>
          <v-card-title class="orange lighten-3">
            <span class="white--text">Completed</span>
          </v-card-title>
          <v-divider horizontal></v-divider>
          <v-card-text class="orange lighten-3">
            <draggable class="list-group kanban-column" :list="Completed" group="tasks" :move="onDrop">
              <v-card
                class="#f4f5fa"
                style="height:auto; margin-top:10px"
                v-for="issue in Completed"
                :key="issue"
                align-center
                elevation="3"
              >
                <v-card-text>
                  <v-row dense style="width:auto">
                    <router-link
                      class="d-flex align-center text-decoration-none grey--text"
                      style="font-size:18px;"
                      :to="{ name: 'IssuePage', params: { id: issue.id, issue } }"
                    >
                      {{ issue.title }}
                    </router-link>
                  </v-row>

                  <v-row dense>
                    <v-col>
                      <v-chip
                        class="ma-2"
                        color="red"
                        outlined
                        style="position:relative; right:10px;top:10px; height:min-content"
                      >
                        {{ issue.issueSeverity }}
                      </v-chip>
                    </v-col>
                    <v-col>
                      <v-chip
                        class="ma-2"
                        color="green"
                        outlined
                        style="position:relative; right:83px; top:10px;height:min-content"
                      >
                        {{ issue.issueType }}
                      </v-chip>
                    </v-col>
                  </v-row>
                </v-card-text>
              </v-card>
            </draggable>
          </v-card-text>
        </v-card>
      </v-col>
    </v-row>
  </v-container>
</template>

<script>
import draggable from 'vuedraggable'
import { mapGetters, mapActions } from 'vuex'

export default {
  props: ['project_id'],

  components: {
    draggable,
  },

  computed: {
    ...mapGetters(['Open','InProgress', 'Completed', 'Statuses', 'Types', 'Severities']),
  },

  watch: {
    project_id() {
      this.fetchIssuesofProject(this.project_id)
      this.test()
    },
  },

  methods: {
    ...mapActions(['fetchIssuesofProject', 'updateIssueStatus']),

    onDrop(evt) {
      const movedIssue = evt.draggedContext.element
      var StatusTag = evt.relatedContext.element.issueStatus
      var TypeTag = evt.relatedContext.element.issueType
      var SeverityTag = evt.relatedContext.element.issueSeverity
      var status = this.Statuses.find(st => st.title == StatusTag)
      var type = this.Types.find(tp => tp.title == TypeTag)
      var severity = this.Severities.find(sv => sv.title == SeverityTag)
    
      const updateIssue = {
        id: movedIssue.id,
        created: movedIssue.created,
        title: movedIssue.title,
        description: movedIssue.description,
        time_estimate: movedIssue.time_estimate,
        userid: 'f3260d22-8b5b-4c40-be1e-d93ba732c576',
        projectid: movedIssue.projectid,
        issueTypeId: type.id,
        issueStatusId: status.id,
        issueSeverityId: severity.id,
      }

      //console.log(updateIssue)

      this.updateIssueStatus(updateIssue)
    },

    test() {
      console.log(this.projectid)
    },
  },

  created() {
    this.test(), this.fetchIssuesofProject(this.project_id), this.getIssueStatus()
  },
}
</script>

<style scoped>
hr {
  margin-top: 0.1px;
  margin-bottom: 0.1px;
  border: 1;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}
</style>

Kanban.js (vuex)

import axios from 'axios'

const state = {
    Issues: [],
}

const getters = {
    Open: (state) => state.Issues.filter(x => x.issueStatus == 'Open'),
    InProgress: (state) => state.Issues.filter(x => x.issueStatus == 'In Progress'),
    Completed: (state) => state.Issues.filter(x => x.issueStatus == 'Closed'),
}

const actions = {
    async fetchIssuesofProject({ commit }, projectid) {
        const response = await axios.get('https://fadiserver.herokuapp.com/api/v1/my-issues-titles/?projectid=' + projectid).catch(error => {
            console.log(error)
        })
        commit('setIssues', response.data)
    },

    async updateIssueStatus({ commit }, issue) {
        const response = await axios.post('https://fadiserver.herokuapp.com/api/v1/my-issues/?id=' + issue.id, issue).catch(error => {
            console.log(error)
        })

        commit('updateIssueStatus', response.data)
    },
}

const mutations = {
    setIssues: (state, Issues) => (state.Issues = Issues),
    updateIssueStatus: (state, Issue) => {
        const index = state.Issues.findIndex(is => is.id == Issue.id)
        if(index !== -1){
            state.Issue.splice(index, 1, Issue)
        }
    }
}

export default {
    state,
    getters,
    actions,
    mutations
}

If you see mapGetters without equivelent mapActions, it is because it is called in another component, so no need to worry about them

Does onclick animation affect SEO?

We want to build the website with mind-blowing animations, but SEO is also important for us and I am wondering about the SEO effects in the case of CSS and JS animations.

Let’s say we want to build the page with Gatsby.js or Next.js and add animations in Three.js. We know that the page needs to be loaded very fast, so we don’t want to use animations on init. But let’s say we want to have a switch button on the top of the website that will trigger the Three.js and CSS animations. Does it affect SEO?

Another example we will have a static website with no animations and a second website with the same content but with a lot of animations and no index tag (flexing purpose). So when the user will visit our website he will be able to see the link (no-follow) to the website on the subdomain with animations.

Any ideas on how to figure it out?

Change colour of dynamic table in java

  1. the cells from the two diagonals shaded either orange or chartreuse;
  2. with the intersecting cell from the diagonals shaded black;
  3. and its text in white

There is a image here and that’s what its suppose to look like.

This is what the table is suppose to look like at the end.

function drawTable() {
            var rows = parseInt(document.getElementById("numRows").value);
            var cols = parseInt(document.getElementById("numColumns").value);

            var theHtmlCode = "";

            theHtmlCode = "<table>";

            theHtmlCode += "<tr>";
            for ( var i=1 ; i<=cols ; i++ ) {
                theHtmlCode += "<th>";
                theHtmlCode += "Column " + i;
                theHtmlCode += "</th>";
            }
            theHtmlCode += "</tr>";



            // create table rows
            for ( var j=1 ; j<=rows ; j++ ) {
                theHtmlCode += "<tr>";

                // create table cells
                for ( var k=1 ; k<=cols ; k++ ) {

                    if (k==j)
                    {
                        theHtmlCode += "<td class='across'>";
                    }
                    else
                    {
                        theHtmlCode += "<td>";
                    }
                    theHtmlCode += j + "." + k;
                    theHtmlCode += "</td>";
                }

                theHtmlCode += "</tr>";
            }
            // close table tag
            theHtmlCode += "</table>";



            document.getElementById("whereTheTableGoes").innerHTML = theHtmlCode;

        }
body { background-color: lightblue}
        h1 {text-align: center}
        td { border: 2px blue solid}
        th { border: 3px red solid}
        img {border: 1px solid black}
        .across {background-color: pink}

      
        tr:nth-child(even) {background-color: #eb00ff;}
<label>How Many Rows Do You Want in the Table?</label>
<input type="number" min="1" id="numRows" placeholder="1 or more"> <br><br>
<label>How Many Columns Do You Want in the Table?</label>
<input type="number" min="1" id="numColumns" placeholder="1 or more"> <br><br>

<button onclick="drawTable()">Click to Draw the Table</button><br><br>

<div id="whereTheTableGoes"></div>

async keyword on synchronous function [duplicate]

I had a bug that a function was declared with async keyword even though it was a synchronous function.
when this function was called in another function, there was a problem that the function changes weren’t available to another function right below.

when I added await – it seems to fixed it.
I don’t understand why. if it was a synchronous function that warped in a promise why did it needed to be blocked with await? or am I missing something

Sorting in Javascript based on 2 parameters

I have a use case wherein I want to sort the below given array

const account = [
{
    currency: "CNY",
    available_balance: 1000
}, 
{
    currency: "HKD",
    available_balance: 100
}, 
{
    currency: "CNY",
    available_balance: 200
}, 
{
    currency: "HKD",
    available_balance: 1500
}];

Now I have to sort it as follows,

const output = [
{
    currency: "CNY",
    available_balance: 1000
},
{
    currency: "CNY",
    available_balance: 200
},
{
    currency: "HKD",
    available_balance: 1500
},
{
    currency: "HKD",
    available_balance: 100
}];

The one with higher balance in CNY is first followed by the lower balances of CNY. After that I want to display HKD with higher balance first.

I was able to sort according to the available_balance but with not currency.

sortedAccount = account.sort((a, b) => {
return b.available_balance - a.available_balance;
});
console.log(sortedAccount);

Please help 🙂
Thank you.

Error: ID strings of the products were saved as an array

I’m trying to store each of the product’s id in the cartItems, however, the ID is being saved as an array as demonstrated in the picture below. Instead of being saved like this id: "aRLMZkiSU7T0lcsPCSsV"

How do I fix this?

enter image description here

code sandbox: https://codesandbox.io/s/add-to-cart-jsd9fd?file=/src/App.js:0-2587

Below are the codes:

export default function App() {
  const [cartItems, setCartItems] = useState([]);

  const handleAdd = (id, name, size, cat, color) => {
    console.log("add", id, name, size, cat, color);
    const productExist = cartItems.find((item) => item.id === id);

    if (productExist) {
      setCartItems(
        cartItems.map((item) =>
          item.id === id
            ? { ...productExist, quantity: productExist.quantity + 1 }
            : item
        )
      );
    } else {
      setCartItems([
        ...cartItems,
        { ...id, name, size, cat, color, quantity: 1 }
      ]);
    }
  };

  // const handleAdd = (item) => {
  //   console.log("add", item);
  // };

  console.log(cartItems);

  return (
    <div className="App">
      {products.map((index) => (
        <ul key={index.id}>
          <li>
            <b>{index.prodName}</b>
          </li>
          <li>Category: {index.cat}</li>
          <li>Size: {index.size}</li>
          {Object.entries(index.colorMap).map((color) => (
            <>
              {color[1] !== 0 ? (
                <>
                  {color[0]}
                  <button
                    onClick={(e) =>
                      handleAdd(
                        index.id,
                        index.prodName,
                        index.size,
                        index.cat,
                        color[0]
                      )
                    }
                  >
                    Add to Cart
                  </button>
                  {/* <button onClick={(e) => handleAdd(index)}>Add to Cart</button> */}
                </>
              ) : (
                <>2</>
              )}
              <br />
            </>
          ))}
          Php {index.price}.00
        </ul>
      ))}
      {/* <Cart cartItems={cartItems} /> */}
    </div>
  );
}

Cannot host react app error from response is something like => You need to enable JavaScript to run this app.

I am testing my react app on my local server by building it using npm run build
Now here I am getting a error my app is hosted properly but whenever I try to login it shows this error on console.
Console Error

Next I am inspecting the network tab it shows
Response is Ok but it gets HTML as a result!

<!doctype html>
<html lang="en">
   <head>
      <title>DDU Placement Portal</title>
      <link rel="icon" href="/ddu_favicon.svg">
      <meta charset="utf-8"/>
      <meta name="viewport" content="width=device-width,initial-scale=1"/>
      <meta name="theme-color" content="#2296f3"/>
      <meta name="title" content="Berry - React Material Admin Dashboard Template by CodedThemes"/>
      <meta name="description" content="Start your next React project with Berry admin template. It build with Reactjs, Material-UI, Redux, and Hook for faster web development."/>
      <meta name="keywords" content="react admin template, material-ui react dashboard template, reactjs admin template, reactjs dashboard, react backend template"/>
      <meta name="author" content="CodedThemes"/>
      <meta property="og:locale" content="en_US"/>
      <meta property="og:type" content="website"/>
      <meta property="og:url" content="https://berrydashboard.io/"/>
      <meta property="og:site_name" content="berrydashboard.io"/>
      <meta property="article:publisher" content="https://www.facebook.com/codedthemes"/>
      <meta property="og:title" content="Berry - React Material Dashboard Template"/>
      <meta property="og:description" content="Berry Dashboard is made for the faster web application development built using Material-UI, Reactjs, Redux & Hook API."/>
      <meta property="og:image" content="https://berrydashboard.io/og-image/og-facebook.png"/>
      <meta property="twitter:card" content="summary_large_image"/>
      <meta property="twitter:url" content="https://berrydashboard.io"/>
      <meta property="twitter:title" content="Berry - React Material Dashboard Template"/>
      <meta property="twitter:description" content="Berry Dashboard is made for the faster web application development built using Material-UI, Reactjs, Redux & Hook API."/>
      <meta property="twitter:image" content="https://berrydashboard.io/og-image/og-twitter.png"/>
      <meta name="twitter:creator" content="@codedthemes"/>
      <link rel="preconnect" href="https://fonts.gstatic.com"/>
      <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Poppins:wght@400;500;600;700&family=Roboto:wght@400;500;700&display=swap" rel="stylesheet"/>
      <script src="https://kit.fontawesome.com/4b9ba14b0f.js" crossorigin="anonymous"></script><script defer="defer" src="/static/js/main.c5c95319.js"></script>
      <link href="/static/css/main.a757dd27.css" rel="stylesheet">
   </head>
   <body>
      <noscript>You need to enable JavaScript to run this app.</noscript>
      <div id="root"></div>
      <script type="text/javascript">!function(t,e,n,c,s,a,r){t[n]=t[n]||function(){(t[n].q=t[n].q||[]).push(arguments)},(a=e.createElement(c)).async=1,a.src="https://www.clarity.ms/tag/6sbb1vpcjo",(r=e.getElementsByTagName(c)[0]).parentNode.insertBefore(a,r)}(window,document,"clarity","script")</script><script async src="https://www.googletagmanager.com/gtag/js?id=G-X1LG1CJ1GG"></script><script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","G-X1LG1CJ1GG"),gtag("event","action",{non_interaction:!0})</script>
   </body>
</html>

Please Help me!

Javascript LinkedList head

Writing LinkedList data structure in Javascript:

class LinkedList {
    constructor() {
        this.head = null;
        this.tail = null;
    }

    add(value) {
        const newNode = {
            value: value,
            next: null
        }

        if(!this.head) {
            this.head = newNode;
        }

        if(this.tail) {
            this.tail.next = newNode;
        }

        this.tail = newNode;

    }
}

const myLinedList = new LinkedList()
myLinedList.add('first value')
myLinedList.add('second values')
myLinedList.add('third values')

console.log(myLinedList)

… i don’t understand how head.next appears as no null. How the next for the head is written? I ask this because i add next only here this.tail.next but i don’t have any this.head.next.

Click multiple: true cypress

I have a page where I land that have about 15 icons on it all with the same source. The way im grabbing each element looks like this:

cy.get('[src="someSource"]').click({ multiple: true })

The issue that have is that after clicking on an icon I have a model that pops up where I need to click another button before I can continue to the next icon.

I there a way for me to add another click in between each of these icons ?

How to clear input field and reset select option after creating data in react

I am new to react, I am trying to create a form with some fields. but I don’t know how to clear my input field after inserting data and I would also like my select option to go back to the default “Select option”.

const AddBook = () => {
const [authors, setAuthors] = useState([]);
const [book, setBook] = useState([]);
const { loading, data } = useQuery(getAuthorsQuery)
const [addBook] = useMutation(addBookMutation)

const handleSubmit = (e) => {
    e.preventDefault();
    addBook({
        variables: {
            name: book.name,
            genre: book.genre,
            authorId: book.authorId    
        },
        refetchQueries:[{query:getBooksQuery}]
    })
    
}

const handleChange = (e) => {
   
   setBook({...book,[e.target.name]: e.target.value})
}

useEffect(() => {
    if (!loading) {
        setAuthors(data.authors)
    }
}, [data, loading]);
return (
    <form id="add-book" onSubmit={handleSubmit}>
        <div className='field'>
            <label>Book name</label>
            <input type="text" name="name" onChange={handleChange}/>
        </div>
        <div className='field'>
            <label>Genre</label>
            <input type="text" name="genre" onChange={handleChange}/>
        </div>
        <div className='field'>
            <label>Author</label>
            <select name="authorId" onChange={handleChange}>
                <option>Select Option</option>
                {authors.map(author => <option name="authorId" key={author.id} value={author.id}>{author.name}</option>)}
            </select>
        </div>
        <button>Add Book</button>
    </form>

)

};

export default AddBook

Interactjs position draggable objects

i want to align multiple draggable elements inside a div. How can i do when i initiate it.

HTML:

<div class="drag-parent" style="height: 400px; width: 400px; background: #fff; border: 1px solid #eee;">
       <div class="drag-1" id="drag1"> Draggable Element 1 </div>
        <div class="drag-2" id="drag2"> Draggable Element  2</div>
</div>

I am trying following things:

const drag1 = interact('.drag-1');
const drag2 = interact('.drag-2');

drag1.draggable({});
drag2.draggable({});

I want to place above elements lets say drag-1 to x:10 y:10 and drag-2 to x:100, y:100.

Please guide.
Thanks!