'js' Category

  • How to show packed sprites with CSS and scale them

    July 11, 2022

    Example:     Reactjs component and calculations: import React from 'react'; type props = { width: number, height: number, frame: { x: number, y: number, w: number, h: number }, textureUrl: string, background?: string, }; class TextureImageResizeComponent extends React.Component<props> { render() { let { width, height, background, frame, textureUrl, } = this.props; if (width === […]

  • Simple JavaScript seconds counter

    November 19, 2019

    /** * @author Ivan Gospodinow * @site http://ivangospodinow.com/?p=471 * * @param {callback} onUpdate * @return {callback} onStop */ export function countSeconds(onUpdate) { const start = new Date(); const interval = setInterval(() => { onUpdate(parseInt((new Date().getTime() – start.getTime()) / 1000)); }, 1000); return () => { clearInterval(interval); }; }   Usage: /** let seconds = 0; […]

  • How to use Zopim chat outside your site.

    June 11, 2013

    Most of the time Zopim chat makes your site slower.Here is an example how you can make your site load faster using Zopim chat. Step 1. Create html page zopim.html and put this code inside: Step 2. Go to the page where you want to put Zopim chat and put this code: That is! It […]

  • Simple way to validate email in javascript

    February 15, 2013

    Just use : function isMail(email) { var re = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; return re.test(email); } Simple as that.

  • jQuery delayed events.

    February 1, 2013

    onDelay is simple jquery plugin that trigger events with delay. /** * Trigger event delayed. * @author Ivan Gospodinow * @site http://www.ivangospodinow.com * @mail ivangospodinow@gmail.com * @date 01.02.2013 */ (function($) { $.fn.onDelay = function(type, delay, funct) { delay = undefined === delay ? 500 : parseInt(delay); var timeOut; $(this).unbind(type)[type](function(e,x,y,z) { clearTimeout(timeOut); var self = this; […]


Warning: Use of undefined constant XML - assumed 'XML' (this will throw an Error in a future version of PHP) in /home/c2kblate/sites/ivangospodinow.com/wp-content/plugins/wp-syntaxhighlighter/wp-syntaxhighlighter.php on line 1048
 
Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org