Found 598 Articles for Front End Scripts

Is HTML5 canvas and image on polygon possible?

George John
Updated on 25-Jun-2020 08:15:15

424 Views

Yes, it is possible. Create a pattern using the image, and then set the pattern to fillStyle.Here, obj is our image object −var context = canvas.getContext("2d"); var pattern = context.createPattern(obj, "repeat"); context.fillStyle = pattern;You need to manipulate the image to fit an arbitrary polygon −context.save(); context.setTransform(m11, m12, m21, m22, dx, dy); context.drawImage(obj); context.restore();

Detect folders in Safari with HTML5

Smita Kapse
Updated on 25-Jun-2020 08:02:02

143 Views

You can try to run the following code to detect folders in Safari −Array.prototype.forEach.call(e.dataTransfer.files, function (file) {    var r = new FileReader();    r.onload = function (event) {       addFile(file);    };    r.onerror = function (event) {       alert("Uploading folders isn't supported in Safari browser!");    }    r.readAsDataURL(file); });

Creating content with HTML5 Canvas much more complicated than authoring with Flash

Anvi Jain
Updated on 28-Jan-2020 07:44:40

150 Views

Flash provides amazing GUI and lots of visual features for animations. It allows the user build everything inside a particular platform without a full integration into the browser wrapped inside the browser with the main scopes that are multimedia and other kinds of animation.HTML5 element gives you an easy and powerful way to draw graphics using JavaScript. It can be used to draw graphs, make photo compositions or do simple (and not so simple) animations.Here is a simple element which has only two specific attributes width and height plus all the core HTML5 attributes like id, name, and ... Read More

HTML5 Canvas Degree Symbol

Arjun Thakur
Updated on 05-Apr-2022 12:35:42

449 Views

For HTML5 Canvas degree symbol, try to run the following code −                          body {             margin:5em;             background:#eee;             text-align:center          }          canvas {             background:#fff;             border:2px solid #ccc;             display:block;             margin:3em auto          }                              var c = document.getElementsByTagName('canvas')[0];          c.width = c.height = 300;          var context = c.getContext('2d');          context.font = "20px sans-serif";          context.fillText("212° Fahrenheit", 100, 100);          

How to stop dragend's default behavior in drag and drop?

Ankith Reddy
Updated on 25-Jun-2020 08:04:08

212 Views

To stop dragend’s default behavior, you need to detect if the mouse is over the drop target where you want to drop.This is what you should do only if you are hovering over my list − listContainer.insertBefore(source, myNode);Use jQuery −if ($(mylist).parent().find(":hover")) {    listContainer.insertBefore(source, myNode); }

Proper use of flex properties when nesting flex containers

AmitDiwan
Updated on 06-Dec-2022 10:55:50

1K+ Views

A flex container is always the parent and a flex item is always the child. The scope of a flex formatting context is limited to a parent/child relationship. Descendants of a flex container beyond the children are not part of flex layout and will not accept flex properties. There are certain flex properties that apply only to flex containers − justify-content, flex-wrap andflex-direction There are certain flex properties that apply only to flex items” align-self flex-grow flex Always apply display: flex or display: inline-flex to a parent in order to apply flex properties to the child. Let ... Read More

HTML5 Canvas Font Size Based on Canvas Size

George John
Updated on 25-Jun-2020 08:05:40

835 Views

To scale fonts, let us see an example.Canvas: 800px Font Size: 60pxYou need to use the following code for our example to scale font size based on canvas −var fontBase = 800; var fontSize = 60; function getFont() {    var ratio = fontSize / fontBase;    var cSize = canvas.width * ratio;    return (cSize |0) + 'px sans-serif'; }

How to make an Ember.js app offline with server sync when available?

Arjun Thakur
Updated on 25-Jun-2020 07:55:53

121 Views

Use the ember-localstorage adapter.App.store = DS.Store.create({    revision: 11,    adapter: DS.LSAdapter.create() });ExampleYou need to define the adapter you want to use for client-side storage −App.Store = DS.SyncStore.extend({    revision: 10,    adapter: DS.IndexedDB.adapter({       mappings: {          person: App.Person,          persons: App.Person,          contact: App.Contact,          contacts: App.Contact       }    }) });

How to make the user login for an offline web app?

George John
Updated on 30-Jul-2019 22:30:22

486 Views

While logging in i.e. online, you need to first authenticate against the server and if it works, store the username and a hashed password in the database.If you can find the account in the database, then you need to generate a new hash, only if the user has changed the password since the last time he logged.You need to also authenticate against the local database. Log in using the online version of the app at least once.

HTML5 video full preload in JavaScript

Chandu yadav
Updated on 25-Jun-2020 07:58:43

814 Views

Use the oncanplaythrough event to completely preload video. You can try to run the following code.Example                                        Your browser does not support the video element.                      function display() {             alert("Can be played without pausing for buffering.");         }

Advertisements