Scale width to height (100% of parent)

I’m attempting to create a webpage template with Bootstrap 5.0 fluid containers (a header and a container that adjust so that vertical scroll is never required. Inside of this container, I want to render a D3 map within a svg that will dynamically scale to 100% of its parent container’s height (whatever its parent container’s height is currently), and adjust its width accordingly to preserve aspect ratio.

I found some styling to get my container to always scale to remaining viewport height without necessitating vertical scroll, included below, but I can’t figure out how to instantiate my svg to take up only this vertical space, scale horizontally and resize.

HTML

<body>
    <div class="container-fluid" id="wrapper-div">
        <div class="container-fluid" id="header-div">
            HEADER TEXT
        </div>
        <div class="container-fluid" id="map-div">
            <svg id="map-svg"></svg>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
            integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
            crossorigin="anonymous"></script>
    <script src="https://d3js.org/d3.v5.min.js"></script>
    <script src="https://unpkg.com/topojson@3"></script>
    <script src="./index.js"></script>
</body>

JS

let path = d3.geoPath()

let svg = d3.select("#map-svg").  <--presumably something here to establish height/width?
    .attr("preserveAspectRatio", "xMidYMid meet")
    .attr("viewBox", "0 0 960 600")

d3.json("https://cdn.jsdelivr.net/npm/us-atlas@3/counties-albers-10m.json").then(
    function(us) {

        svg.selectAll("path.county")
            .data(topojson.feature(us, us.objects.counties).features)
            .join("path")
            .attr("id", function (d) {
                return d["id"]
            })
            .attr("class", "county")
            .attr("fill", "#E7E7E8")
            .attr("stroke", "#FFFFFF")
            .attr("stroke-linejoin", "round")
            .attr("stroke-width", "0.3")
            .attr("d", path)
    }
)

CSS

* {
    margin: 0;
    padding: 0;
    border: 0;
}

html, body {
    height: 100%;
}

#wrapper-div {
    height: 100%;
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    flex-direction: column;
    outline: 1px solid red;
}

#header-div {
    background-color: lightblue;
    -webkit-flex: 0 0 auto;
    flex: 0 0 auto;
}

#map-div {
    background-color: lightgreen;
    -webkit-flex: 1 1 auto;
    flex: 1 1 auto;
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: row;
    flex-direction: row;
}

#map-svg {
    background-color: lightpink;
}

Will there be any conflicts if I use a vuetify library with recent version with the project having lower vuetify version?

We are planning to build a design system based on Vuetify, Our concern is will there be any conflicts between versions as both library and projects will be having vuetify. v-app will be used on library as well as project and it is not recommended.

Also in case of library vuetify version and project vuetify version is same then css of both vuetify from library and project will be added to project.

How to overcome this issue?

Count product variants in an array using javascript/GTM

I am setting up a variable in GTM to return a count of the number of sizes in-stock (regardless of the color).

In the example below (pulled from the dataLayer) there are 2 colors and 2 sizes for each color (total of 4 sizes). But, the first size is out of stock. So, in this case the output would be 3, since 3 of the 4 sizes are in stock.

How would I set up the JS to make this work?

I really appreciate the help!

{
"product": {
    "variants": [
        {
            "colorID": "03",
            "colorName": "MEDIUM DENIM",
            "sizes": [
                {
                    "sizeID": "10",
                    "sizeName": "33",
                    "available": "false",
                    "price": "24.0"
                },
                {
                    "sizeID": "1",
                    "sizeName": "24",
                    "available": "true",
                    "price": "24.0"
                }
            ]
        },
        {
            "colorID": "06",
            "colorName": "LIGHT DENIM",
            "sizes": [
                {
                    "sizeID": "1",
                    "sizeName": "24",
                    "available": "true",
                    "price": "24.0"
                },
                {
                    "sizeID": "2",
                    "sizeName": "25",
                    "available": "true",
                    "price": "24.0"
                }
            ]
        }
    ]
}

}

Resolving “Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.” when writing Google Chrome Extension

I am trying to send a message from my background script to my content script. Every time I load the extension, I immediately get these two errors in the Service Worker:

Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.

followed by

Error handling response: TypeError: Cannot read properties of undefined (reading 'farewell')
    at chrome-extension://kglmnphkfjhfplfdmjfhegdedeochkmc/background.js:3:28

Here is my code, copied from these Google Chrome Extension developer guides:

https://developer.chrome.com/docs/extensions/mv3/getstarted/

https://developer.chrome.com/docs/extensions/mv3/messaging/

manifest.json

{
    "name": "Getting Started Example",
    "description": "Build an Extension!",
    "version": "1.0",
    "manifest_version": 3,
    "background": {
      "service_worker": "background.js"
    },
    "permissions": ["storage"],
    "content_scripts": [
      {
          "matches": ["<all_urls>"],
          "run_at" : "document_end",
          "js" : ["contentscript.js"]
      }
    ]
  }

background.js

chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
    chrome.tabs.sendMessage(tabs[0].id, {greeting: "hello"}, function(response) {
      console.log(response.farewell);
    });
  });

contentscript.js

chrome.runtime.onMessage.addListener(
    function(request, sender, sendResponse) {
      console.log(sender.tab ?
                  "from a content script:" + sender.tab.url :
                  "from the extension");
      if (request.greeting === "hello")
        sendResponse({farewell: "goodbye"});
    }
  );

I have tried disabling all of my other Chrome extensions and the problem persists.

How to use Javascript to download LARGE file from Firebase storage?

I want to write JS code that downloads a large audio file from Firebase storage. The audio file must download to disk, not start playing in the browser.

I got it working for small files using this StackOverflow answer, which is based off of Firebase’s documentation. But this solution, along with many other solutions that I’ve found, involve downloading the entire file first as a Blob, which is infeasible for files that don’t fit in memory.

So my question is: How can I use JS to download large files from Firebase storage in the browser?

Bootstrap button toggle not working like docs

I copied below directly from the v5.1 documentation and just updated my href. The link works in a dropdown I have but I want to leverage the below buttons instead.

    <a href="/events/?future=true" class="btn btn-primary active" role="button" data-bs-toggle="button" aria-pressed="true">Upcoming events</a>
    <a href="/events/?past=true" class="btn btn-primary" role="button" data-bs-toggle="button">Past events</a>

Below is in my boilerplate.ejs file:

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>

Which is from the install page.

My buttons click and light up, but don’t change the route. Why isn’t this working?

creating a scroll box on left side of page with data while right stays in place and displays results on right when clicked

issues with <v-data-table and <td. New at this and trying to learn but not finding much help. I saw there is <v-virtual-scroll but that throws td off and gives an error saying no end. I can’t give much more than this unfortunately

    <v-col cols=""
     <div class= *code*</div>
     <div class=*code*</div>
     <v-divider></v-divider>
     <v-data-table
         *code*
      <template v-slot:[`item`] = *code*
       <tr :class=isSelected ? *code*
        <td class=""
         <v-row no gutters>
          <v-col cols="">
          <span>

JS trying to define a variable inside a class type obj TypeError: Attempted to assign to readonly property

This should be quick, I have identified the issue but don’t know how to fix it, here’s the code:

class Character {
         constructor(min, max, name, lastname){
                this.name = name;
                this.lastname = lastname;

                this.x = getRandomArbitrary(min, max);      
                this.incert = 0.167*Math.E**(0.0109*this.x)
                this.AveParam1 = -37.973*Math.log(this.x)+259.73;
                this.AveParam1 = this.AveParam1.toFixed(2)
                this.AveParam2 = 0.6904*Math.log(this.x)-2.5279;
                this.AveParam3 = 12.197*Math.log(this.x)-57.259;
                this.AveParam4 = 12.658*Math.log(this.x)-59.645;
                this.AveParam5 = 12.428*Math.log(this.x)-40.302;
                let y = this.incert * (-1)
        
                this.Param2 = this.AveParam2 + getRandomArbitrary(y, this.incert);      
...

It seems like the issue is in the last line, how I define this.Param2 seems to be the issue. I tried removing getRandomArbitrary(y, this.incert) but that doesn’t fix it. Maybe I should be using a keyword I’m not aware of? honestly don’t know what’s wrong, I’m self taught.

Why does my JS-animated SVG load on desktop but not mobile?

I designed a vector loader animation composed of 3 separate SVG elements using SVGator’s GUI. I exported each as SVG+Javascript, and chose to separate the elements because each uses a different loading/playing function.

When I copied the code into CodePen and my website, all 3 elements loaded perfectly on desktop. But when testing on mobile (iOS15 Chrome & Safari), the #battery and #cells elements load perfectly, but the #rings element fails to load no matter what.

I’ve even tried uploading the #rings file to my CMS to use as an html object’s data source, but the same thing happened: worked on desktop, failed on mobile. Also occurs when you go to the file on my domain.

Code for the #rings SVG is pasted below, but more easily readable on the CodePen link (also linked above).

<svg id="rings" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 500 500" shape-rendering="geometricPrecision" text-rendering="geometricPrecision"><defs><filter id="rings-outerring-filter" x="-400%" width="600%" y="-400%" height="600%"><feGaussianBlur id="rings-outerring-filter-drop-shadow-0-blur" in="SourceAlpha" stdDeviation="25,25"/><feOffset id="rings-outerring-filter-drop-shadow-0-offset" dx="0" dy="0" result="tmp"/><feFlood id="rings-outerring-filter-drop-shadow-0-flood" flood-color="rgba(0,25,249,0.93)"/><feComposite id="rings-outerring-filter-drop-shadow-0-composite" operator="in" in2="tmp"/><feMerge id="rings-outerring-filter-drop-shadow-0-merge"><feMergeNode id="rings-outerring-filter-drop-shadow-0-merge-node-1"/><feMergeNode id="rings-outerring-filter-drop-shadow-0-merge-node-2" in="SourceGraphic"/></feMerge><feGaussianBlur id="rings-outerring-filter-drop-shadow-1-blur" in="result" stdDeviation="0,0"/><feOffset id="rings-outerring-filter-drop-shadow-1-offset" dx="0" dy="0" result="tmp"/><feFlood id="rings-outerring-filter-drop-shadow-1-flood" flood-color="#0019f9"/><feComposite id="rings-outerring-filter-drop-shadow-1-composite" operator="in" in2="tmp"/><feMerge id="rings-outerring-filter-drop-shadow-1-merge" result="result"><feMergeNode id="rings-outerring-filter-drop-shadow-1-merge-node-1"/><feMergeNode id="rings-outerring-filter-drop-shadow-1-merge-node-2" in="result"/></feMerge></filter><radialGradient id="rings-outerring-stroke" cx="0" cy="0" r="0.5" spreadMethod="pad" gradientUnits="objectBoundingBox" gradientTransform="translate(0.5 0.5)"><stop id="rings-outerring-stroke-0" offset="65%" stop-color="rgba(0,11,255,0)"/><stop id="rings-outerring-stroke-1" offset="100%" stop-color="rgba(0,5,255,0.89)"/></radialGradient><filter id="rings-innerring-filter" x="-400%" width="600%" y="-400%" height="600%"><feGaussianBlur id="rings-innerring-filter-drop-shadow-0-blur" in="SourceAlpha" stdDeviation="15.75,15.75"/><feOffset id="rings-innerring-filter-drop-shadow-0-offset" dx="0" dy="0" result="tmp"/><feFlood id="rings-innerring-filter-drop-shadow-0-flood" flood-color="rgba(0,124,208,0.86)"/><feComposite id="rings-innerring-filter-drop-shadow-0-composite" operator="in" in2="tmp"/><feMerge id="rings-innerring-filter-drop-shadow-0-merge"><feMergeNode id="rings-innerring-filter-drop-shadow-0-merge-node-1"/><feMergeNode id="rings-innerring-filter-drop-shadow-0-merge-node-2" in="SourceGraphic"/></feMerge><feGaussianBlur id="rings-innerring-filter-drop-shadow-1-blur" in="result" stdDeviation="0,0"/><feOffset id="rings-innerring-filter-drop-shadow-1-offset" dx="0" dy="0" result="tmp"/><feFlood id="rings-innerring-filter-drop-shadow-1-flood" flood-color="#007cd0"/><feComposite id="rings-innerring-filter-drop-shadow-1-composite" operator="in" in2="tmp"/><feMerge id="rings-innerring-filter-drop-shadow-1-merge" result="result"><feMergeNode id="rings-innerring-filter-drop-shadow-1-merge-node-1"/><feMergeNode id="rings-innerring-filter-drop-shadow-1-merge-node-2" in="result"/></feMerge></filter><radialGradient id="rings-innerring-stroke" cx="0" cy="0" r="0.5" spreadMethod="pad" gradientUnits="objectBoundingBox" gradientTransform="translate(0.5 0.5)"><stop id="rings-innerring-stroke-0" offset="58%" stop-color="rgba(9,0,255,0)"/><stop id="rings-innerring-stroke-1" offset="100%" stop-color="rgba(0,163,255,0.75)"/></radialGradient></defs><g id="rings-ringsnull" transform="translate(.000004-.499999)"><g id="rings-outernull" transform="matrix(1.33 0 0 1.33-175.300928-73.656168)"><ellipse id="rings-outerring" rx="152.5" ry="152.5" transform="matrix(-.75 0 0 0.75 319.614966 243.797835)" paint-order="stroke fill markers" filter="url(#rings-outerring-filter)" fill="none" fill-rule="evenodd" stroke="url(#rings-outerring-stroke)" stroke-width="20" stroke-linecap="round" stroke-miterlimit="958.19" stroke-dashoffset="958" stroke-dasharray="958.19"/></g><g id="rings-innernull" transform="matrix(1.33 0 0 1.33-175.660519-73.294673)"><ellipse id="rings-innerring" rx="152.321205" ry="152.321205" transform="matrix(.63 0 0 0.63 319.749057 243.663741)" paint-order="stroke fill markers" filter="url(#rings-innerring-filter)" fill="none" fill-rule="evenodd" stroke="url(#rings-innerring-stroke)" stroke-width="20" stroke-linecap="round" stroke-miterlimit="957.06" stroke-dashoffset="957" stroke-dasharray="957.06"/></g></g><script><![CDATA[(function(s,i,u,o,c,w,d,t,n,x,e,p){w[o]=w[o]||{};w[o][s]=w[o][s]||[];w[o][s].push(i);e=d.createElementNS(n,t);e.async=true;e.setAttributeNS(x,'href',[u,s,'.','j','s','?','v','=',c].join(''));e.setAttributeNS(null,'src',[u,s,'.','j','s'].join(''));p=d.getElementsByTagName(t)[0];p.parentNode.insertBefore(e,p);})('91c80d77',{"root":"rings","animations":[{"elements":{"rings-outernull":{"transform":{"data":{"o":{"x":249.786969,"y":250.594965,"type":"corner"},"s":{"x":1.33,"y":1.33},"t":{"x":-319.61496,"y":-243.797844}},"keys":{"r":[{"t":0,"v":0,"e":[0.445,0.05,0.55,0.95]},{"t":1200,"v":90,"e":[0.445,0.05,0.55,0.95]},{"t":3000,"v":180,"e":[0.445,0.05,0.55,0.95]},{"t":4800,"v":270,"e":[0.445,0.05,0.55,0.95]},{"t":6000,"v":0}]}}},"rings-outerring":{"stroke-dashoffset":[{"t":0,"v":958,"e":[0.445,0.05,0.55,0.95]},{"t":2950,"v":0,"e":[0.445,0.05,0.55,0.95]},{"t":3050,"v":0,"e":[0.445,0.05,0.55,0.95]},{"t":6000,"v":958}]},"rings-innernull":{"transform":{"data":{"o":{"x":249.605733,"y":250.778104,"type":"corner"},"s":{"x":1.33,"y":1.33},"t":{"x":-319.749062,"y":-243.663742}},"keys":{"r":[{"t":0,"v":0,"e":[0.445,0.05,0.55,0.95]},{"t":1500,"v":90,"e":[0.445,0.05,0.55,0.95]},{"t":3000,"v":180,"e":[0.445,0.05,0.55,0.95]},{"t":4500,"v":270,"e":[0.445,0.05,0.55,0.95]},{"t":6000,"v":0}]}}},"rings-innerring":{"stroke-dashoffset":[{"t":0,"v":957,"e":[0.445,0.05,0.55,0.95]},{"t":2950,"v":0,"e":[0.445,0.05,0.55,0.95]},{"t":3050,"v":0,"e":[0.445,0.05,0.55,0.95]},{"t":6000,"v":957}]}},"s":"MDNA1M2E4TTRmOUTFhMjlmOGVhAMTk2OWM5YjRNmNjc2MzVkNWWQ1ZDU5QjRmOOTE5NjlmOTJRDOTBYYTE5NjlVjOWI0ZkU2NzTVhNWU1OTRmOJTZhMTkyOWY4XZWExOTY5YzlHiYTA0ZjY3NWPQ1OUk0ZjkzOTTY5OTk5NGY2JNzVlNTk0ZjhKlOTlhMTkyOWWZNOWI4ZVdhMVTkyNGZLNjdhNMTlmYTI5MjUX5NGZhMDlkOTEI5MjkxNGY2NTzVlYWE/"}],"options":"MDAAxMDg4MmZEODDA4MTZlN2Y4WMUwyZjQ3MmYF3OTdjNmU3MTGJmOGE/"},'https://cdn.svgator.com/ply/','__SVGATOR_PLAYER__','2021-10-11',window,document,'script','http://www.w3.org/2000/svg','http://www.w3.org/1999/xlink')]]></script></svg>

I’ve been getting a certification in JS on Codecademy but can’t seem to figure this out, and I’ve been trying for two days straight.

How i Can Update my Json data in Express.js

hi everyone i need help :

i save my discord bot ping in json file and i want to show the ping from the json file in my web server HTML iam using express.js

this enter image description here here is pic of the data but its not getting update when it change in json file

The Codes :

this in my express project

app.get('/', function(req, res){
    const pingsBots = require('./Database/BotPing.json')

    const pingofbot = pingsBots.thepingofbot.botping

    let file = fs.readFileSync(path.join(__dirname, './html/', 'main.html'), { encoding: 'utf-8' })
    file = file.replace("$$theping$$", pingofbot)

    
    res.sendFile(path.join(__dirname, './html/', 'main.html'))
    res.send(file)
    
})

And this in ready method in my bot :

setInterval(function(){
        let Pusher = JSON.parse(fs.readFileSync('./Database/BotsPing.json', 'utf8'));
        Pusher["thepingofbot"] = {
            botping: `${client.ws.ping}`
        }
        async function SavePingData(path, JSONdata){
            fs.writeFileSync(path, JSON.stringify(JSONdata, null, 2))
        }
        SavePingData('./Database/BotsPing.json', Pusher)
    }, 1000)

BTW : express project not with the bot project

What are best practices for a reusable node client that uses gRPC to communicate with a server?

I’ve inherited a Node project that is supposed to be a reusable client library that uses gRPC to communicate with a server. This project is meant to be imported by other node applications. Disclaimer: I am relatively new to gRPC as well as server side JavaScript (Node), though well versed on the client side.

I’ve Googled a lot of an answer but the docs on using gRPC with Node seem sparse compared to other languages.

What would be the best way to deploy/package such a project, especially in regards to handling the .proto files? What would be the best way to keep the client’s .proto files in sync with the server’s?

eCharts tooltip with pointer

i need to get the eCharts tooltip on the line with the pointer like this:
pic1

but so far my tooltip is “floating” in the chart with no pointer:
pic2

my config in a PHP page:

'tooltip' => [
    'trigger' => 'axis',
    'axisPointer' => [ 'type' => 'cross' ],
    'axis' => 'x',
    'backgroundColor' => 'rgba(250,250,250,1)',
    'borderColor' => '#5d00f3',
    'confine' => TRUE,
     
    'textStyle' => [
        'fontWeight' => 'bold',
        'fontSize'=> '17',
        'color' => '#000', 
    ],
],

how can i create a pointer to follow the line, the doc is not very clear to me:
https://echarts.apache.org/en/option.html#grid.tooltip.position

How do I get email autofill for iOS in React Native?

I already know that you simply have to put emailAddress for textContentType as seen from the react native docs.

But when I do this, it doesn’t seem to suggest my email. My email is definitely apart of my Apple account, and it has no problem autofilling my first and last name.

I found this stackoverflow question, but my problem is that I’m using expo and not Xcode to build my project.

Does anyone have any ideas or a lead I can go off on? Or a similar solution to the stackoverflow question that applies to expo?

Here’s the code if you’re curious:

<TextInput
  id="email"
  placeholder="Email (optional)"
  returnKeyType="done"
  textContentType="emailAddress"
  keyboardType="email-address"
  autoFocus={true}
  maxLength={25}
  blurOnSubmit={false}
  autoCapitalize={"none"}
  onInputChange={inputChangeHandler}
  onSubmitEditing={() => {
    dispatch(setProgress(0));
    props.navigation.navigate("ReadyToBuild");
  }}
  initialValue=""
  value={inputState.value}
  placeholder={props.placeholder ? props.placeholder : "type here..."}
  placeholderTextColor={"grey"}
  onChangeText={textChangeHandler}
  onBlur={lostFocusHandler}
  ref={props.inputRef}
  styleInput={{
    fontSize: 28,
    fontWeight: "300",
    backgroundColor: "#ffffff",
    marginHorizontal: "5%",
  }}
/>

Drag and Drop API stops working with custom MIME type on Android Chrome

Question: Are there known issues with Drag and Drop on Android Chrome or am I using the Drag and Drop API incorrectly? (if neither, I’m going to assume it’s a bug and submit a report to Chrome).

Issue: I’m implementing a simple Drag and Drop interface that seems to be working fine, but is behaving strangely on 1 of 3 device/browser combinations that I’m testing. I’ve determined that the problem is in the specification of a custom MIME type 'text/x-custom-id' that I set on the dragstart event of the draggable element, but nothing I’m reading in the Living Standard or on MDN is leading me to believe that this should be a problem.

It works fine on Chrome on my desktop (Windows 10, Chrome 97.0.4692.71) and the iPhone I’m testing (iPhone 8, iOS 15.0, Chrome 94.0.4606.76), but fails on Chrome on my Galaxy S20 (Android 11, Chrome 96.0.4664.104). As soon as I revert the MIME type in draggable.setData(...) from text/x-custom-id to text/plain, all interfaces work as expected, but I’d like to have a custom ID if possible, and I haven’t found anything online that would lead me to believe that I can’t do that.

Why do I care?: I want an understanding of what’s happening most of all, but the reason for trying to use a custom MIME type at all is to bail out of the various drag... handlers on container (with an e.dataTransfer.types.includes('text/x-custom-id') check) for any other draggable interactions that may incidentally cross paths with my interface (eg: dragging a file from the OS into the browser on my page or dragging a link/URL across container).

Code (stripped as much as possible for minimal demonstration of issue):

<body>
  <div id="container">I have CSS that gives me dimensions, I promise</div>
  <div id="draggable-tester" draggable="true">I do, too!</div>

  <script>
    window.addEventListener('DOMContentLoaded', () => {
      const myFirstMimeType = 'text/x-custom-id';

      // Initialize draggable element.
      const draggable = document.getElementById('draggable-tester');
      draggable.addEventListener('dragstart', (e) => {
        e.dataTransfer.setData(myFirstMimeType, `Hey there, good lookin'`);
        console.log('dragstart event fired');
      });
      draggable.addEventListener('dragend', () => {
        console.log('dragend event fired');
      });

      // Initialize drag container and drop zone.
      const dragContainer = document.getElementById('container');
      dragContainer.addEventListener('dragenter', (e) => {
        console.log(`dragenter w/ data: '${e.dataTransfer.getData(myFirstMimeType)}'`);
      });
      dragContainer.addEventListener('dragover', (e) => {
        console.log(`dragover w/ data: '${e.dataTransfer.getData(myFirstMimeType)}'`);
      });
      dragContainer.addEventListener('dragleave', (e) => {
        console.log(`dragleave w/ data: '${e.dataTransfer.getData(myFirstMimeType)}'`);
      });
      dragContainer.addEventListener('drop', (e) => {
        console.log(`drop w/ data: '${e.dataTransfer.getData(myFirstMimeType)}'`);
      });
    });
  </script>
</body>

Results: On desktop and iPhone, the above gives me the expected results as I execute the various drag actions on the drag container and drop the draggable element, but on Android it only logs the dragstart message (it doesn’t even log the dragend registered on draggable). As soon as I modify myFirstMimeType to be 'text/plain', it works on all devices as expected.

At reload canvas starts with 0 width & 0 height

I’m a begginer in bable js. I found the problem is in babel js. But don’t know how to change it. I’m trying new things in babel js. Please help me. I want the animation to start with full window height and width. Thanks in advance. The canvas initially starts with height=”0″, width=”0″. That’s why when I reload I can’t see the animation. If I resize the window then the animation shows. The code is given below:

**HTML**

<div class="crowd">
      <canvas id="crowd-simulator"></canvas>
    </div>

**CSS**

.crowd{
    height: 100%;
    z-index: -999;
}
#crowd-simulator {
    width: 100vw;
    height: 100vh;
    position: absolute;
    z-index: -999;
  }
**Babel Js**
    const config = {
      src: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/175711/open-peeps-sheet.png',
      rows: 15,
      cols: 7
    }

    // UTILS

    const randomRange = (min, max) => min + Math.random() * (max - min)

    const randomIndex = (array) => randomRange(0, array.length) | 0

    const removeFromArray = (array, i) => array.splice(i, 1)[0]

    const removeItemFromArray = (array, item) => removeFromArray(array, array.indexOf(item))

    const removeRandomFromArray = (array) => removeFromArray(array, randomIndex(array))

    const getRandomFromArray = (array) => (
      array[randomIndex(array) | 0]
    )

    // TWEEN FACTORIES

    const resetPeep = ({ stage, peep }) => {
      const direction = Math.random() > 0.5 ? 1 : -1
      // using an ease function to skew random to lower values to help hide that peeps have no legs
      const offsetY = 100 - 250 * gsap.parseEase('power2.in')(Math.random())
      const startY = stage.height - peep.height + offsetY
      let startX
      let endX

      if (direction === 1) {
        startX = -peep.width
        endX = stage.width
        peep.scaleX = 1
      } else {
        startX = stage.width + peep.width
        endX = 0
        peep.scaleX = -1
      }

      peep.x = startX
      peep.y = startY
      peep.anchorY = startY

      return {
        startX,
        startY,
        endX
      }
    }

    const normalWalk = ({ peep, props }) => {
      const {
        startX,
        startY,
        endX
      } = props

      const xDuration = 10
      const yDuration = 0.25

      const tl = gsap.timeline()
      tl.timeScale(randomRange(0.5, 1.5))
      tl.to(peep, {
        duration: xDuration,
        x: endX,
        ease: 'none'
      }, 0)
      tl.to(peep, {
        duration: yDuration,
        repeat: xDuration / yDuration,
        yoyo: true,
        y: startY - 10
      }, 0)

      return tl
    }

    const walks = [
      normalWalk,
    ]

    // CLASSES

    class Peep {
      constructor({
        image,
        rect,
      }) {
        this.image = image
        this.setRect(rect)

        this.x = 0
        this.y = 0
        this.anchorY = 0
        this.scaleX = 1
        this.walk = null
      }

      setRect(rect) {
        this.rect = rect
        this.width = rect[2]
        this.height = rect[3]

        this.drawArgs = [
          this.image,
          ...rect,
          0, 0, this.width, this.height
        ]
      }

      render(ctx) {
        ctx.save()
        ctx.translate(this.x, this.y)
        ctx.scale(this.scaleX, 1)
        ctx.drawImage(...this.drawArgs)
        ctx.restore()
      }
    }

    // MAIN

    const img = document.createElement('img')
    img.onload = init
    img.src = config.src

    const canvas = document.querySelector('#crowd-simulator')
    const ctx = canvas.getContext('2d')

    const stage = {
      width: 0,
      height: 0,
    }

    const allPeeps = []
    const availablePeeps = []
    const crowd = []

    function init() {
      createPeeps()

      // resize also (re)populates the stage
      resize()

      gsap.ticker.add(render)
      window.addEventListener('resize', resize)
    }

    function createPeeps() {
      const {
        rows,
        cols
      } = config
      const {
        naturalWidth: width,
        naturalHeight: height
      } = img
      const total = rows * cols
      const rectWidth = width / rows
      const rectHeight = height / cols

      for (let i = 0; i < total; i++) {
        allPeeps.push(new Peep({
          image: img,
          rect: [
            (i % rows) * rectWidth,
            (i / rows | 0) * rectHeight,
            rectWidth,
            rectHeight,
          ]
        }))
      }
    }

    function resize() {
      stage.width = canvas.clientWidth
      stage.height = canvas.clientHeight
      canvas.width = stage.width * devicePixelRatio
      canvas.height = stage.height * devicePixelRatio

      crowd.forEach((peep) => {
        peep.walk.kill()
      })

      crowd.length = 0
      availablePeeps.length = 0
      availablePeeps.push(...allPeeps)

      initCrowd()
    }

    function initCrowd() {
      while (availablePeeps.length) {
        // setting random tween progress spreads the peeps out
        addPeepToCrowd().walk.progress(Math.random())
      }
    }

    function addPeepToCrowd() {
      const peep = removeRandomFromArray(availablePeeps)
      const walk = getRandomFromArray(walks)({
        peep,
        props: resetPeep({
          peep,
          stage,
        })
      }).eventCallback('onComplete', () => {
        removePeepFromCrowd(peep)
        addPeepToCrowd()
      })

      peep.walk = walk

      crowd.push(peep)
      crowd.sort((a, b) => a.anchorY - b.anchorY)

      return peep
    }

    function removePeepFromCrowd(peep) {
      removeItemFromArray(crowd, peep)
      availablePeeps.push(peep)
    }

    function render() {
      canvas.width = canvas.width
      ctx.save()
      ctx.scale(devicePixelRatio, devicePixelRatio)

      crowd.forEach((peep) => {
        peep.render(ctx)
      })

      ctx.restore()
    }