惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
V2EX
L
LINUX DO - 热门话题
Engineering at Meta
Engineering at Meta
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏
Attack and Defense Labs
Attack and Defense Labs
P
Privacy & Cybersecurity Law Blog
V
Visual Studio Blog
NISL@THU
NISL@THU
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
SecWiki News
SecWiki News
人人都是产品经理
人人都是产品经理
Jina AI
Jina AI
Last Week in AI
Last Week in AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Threatpost
TaoSecurity Blog
TaoSecurity Blog
L
LINUX DO - 最新话题
量子位
Security Latest
Security Latest
博客园 - 司徒正美
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
I
Intezer
P
Privacy International News Feed
P
Palo Alto Networks Blog
爱范儿
爱范儿
有赞技术团队
有赞技术团队
Apple Machine Learning Research
Apple Machine Learning Research
Cloudbric
Cloudbric
P
Proofpoint News Feed
V
Vulnerabilities – Threatpost
阮一峰的网络日志
阮一峰的网络日志
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 三生石上(FineUI控件)
美团技术团队
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
雷峰网
雷峰网
Hugging Face - Blog
Hugging Face - Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
The Cloudflare Blog
博客园_首页
博客园 - 聂微东
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Securelist
Spread Privacy
Spread Privacy
小众软件
小众软件
PCI Perspectives
PCI Perspectives
T
Troy Hunt's Blog

Minko Gechev's blog

skillgrade Unit Tests for AI Agent Skills You Should Care About AI Generative Development LLM-first Web Framework Reactive framework in ~200 lines of JavaScript Managing Angular Are LLMs going to replace us? Prefetching Heuristics Design Patterns in Open Source Projects - Part II Design Patterns in Open Source Projects - Part I What I learned doing 125 public talks - Part I Dynamic imports solve all the problems, right? 5 Angular CLI Features You Didn't Know About Angular quicklink Preloading Strategy Introducing Bazel Schematics for Angular CLI Building TypeScript Projects with Bazel Joining Google Playing Mortal Kombat with TensorFlow.js. Transfer learning and data augmentation Fast, extensible, configurable, and beautiful linter for Go Introducing Guess.js - a toolkit for enabling data-driven user-experiences on the Web Machine Learning-Driven Bundling. The Future of JavaScript Tooling. JavaScript Decorators for Declarative and Readable Code 3 Tricks For Using Redux and Immutable.js with TypeScript Follow Your Dream Career with Open Source. Personal Story. Redux Anti-Patterns - Part 1. State Management. Faster Angular Applications - Understanding Differs. Developing a Custom IterableDiffer Faster Angular Applications - Part 2. Pure Pipes, Pure Functions and Memoization Faster Angular Applications - Part 1. On Push Change Detection and Immutability Understanding Dynamic Scoping and TemplateRef Implementing a Simple Compiler on 25 Lines of JavaScript Developing Statically Typed Programming Language WebVR for a Gamified IDE 7 Angular Tools That You Should Consider Announcing ngrev - Reverse Engineering Tool for Angular Implementing Angular's Dependency Injection in React. Understanding Element Injectors. Distributing an Angular Library - The Brief Guide Angular in Production Ahead-of-Time Compilation in Angular 2.5X Smaller Angular 2 Applications with Google Closure Compiler Using Stripe with Angular (Deprecated) Building an Angular Application for Production Implementing the Missing "resolve" Feature of the Angular 2 Router Scalable Single-Page Application Architecture Managing ambient type definitions and dealing with the "Duplicate identifier" TypeScript error Static Code Analysis of Angular 2 and TypeScript Projects Enforcing Best Practices with Static Code Analysis of Angular 2 Projects ViewChildren and ContentChildren in Angular Dynamically Configuring the Angular's Router Angular 2 Hot Loader Lazy Loading of Route Components in Angular 2 Aspect-Oriented Programming in JavaScript Flux in Depth. Store and Network Communication. Using JSX with TypeScript Flux in Depth. Overview and Components. Even Faster AngularJS Data Structures Boost the Performance of an AngularJS Application Using Immutable Data - Part 2 Angular2 - First Impressions Build Your own Simplified AngularJS in 200 Lines of JavaScript Persistent State of ReactJS Component Boost the Performance of an AngularJS Application Using Immutable Data Processing Binary Protocols with Client-Side JavaScript Stream your Desktop to HTML5 Video Element Multi-User Video Conference with WebRTC Asynchronous calls with ES6 generators Binary Tree iterator with ES6 generators WebRTC chat with React.js AngularJS in Patterns (Part 3) AngularJS in Patterns (Part 2). Services. Using GitHub Pages with Jekyll! AngularJS in Patterns (Part 1). Overview of AngularJS Singleton in JavaScript Express over HTTPS What I get from the JavaScript MV* frameworks Remote Desktop Client with AngularJS and Yeoman The magic of $resource (or simply a client-side Active Record) AngularJS Inheritance Patterns AngularAOP v0.1.0 Advanced JavaScript at Sofia University AngularJS style guide Lazy prefetching of AngularJS partials VNC client on 200 lines of JavaScript Aspect-Oriented Programming with AngularJS CSS3 flipping effect Practical programming with JavaScript Why I should use publish/subscribe in JavaScript JavaScript, the weird parts Functional programming with JavaScript plainvm Looking for performance? Probably you should NOT use [].sort (V8) JavaScript image scaling ELang Caching CSS with localStorage Self-invoking functions in JavaScript (or Immediately Invoked Function Expressions) Asus N56VZ + Ubuntu 12.04 (en) Asus N56VZ + Ubuntu 12.04 Debian Squeeze + LXDE on Google Nexus S (or having some fun while suffering) HTML5 image editor Курсови проекти – ФМИ Carousel Gallery
Color animation plugin for jQuery
2012-01-16 · via Minko Gechev's blog

Edit · Jan 16, 2012 · 3 minutes read · Follow @mgechev JavaScript jQuery

Hi! I haven’t wrote since a long time but there’s so much code and so little time…It’s bad that the biggest part of the code is not open source but what can we do…Last few hours I developed a JavaScript plugin for color animation. Of course for few hours I cant make something with great quality so it’s a little bit unstable (I think) but it works and it’s also valid for the JSLint standards. It uses easy algorithm. I think of the RGB color representation as a three dimensional space with coordinates in the range [0, 255]. The user is sets object with specific color (doesn’t matter background, font…btw that’s still not fully tested) which is actually a point in this three dimensional space. The target is another point in the 3D space so I just move from the first to the second point. I spoke enough. Let’s look at the code:

(function ($) {
    'use strict';
    $.fn.colorAnimation = function (userOptions) {

        var element = this,
            options = {
                property: 'background-color',
                color: '#00ff00',
                interval: 300
            },
            sysVars = {
                rgbColor: {},
                rgbTargetColor: {},
                timeout: null,
                currentInterval: 0,
                animationStep: 10
            };

        $.extend(options, userOptions);

        function getFromHex(hex) {
            var rgb = {};
            if (hex.indexOf('#') >= 0) {
                hex = hex.substr(1, hex.length - 1);
            }
            if (hex.length === 3) {
                hex += hex;
            }
            rgb.red = { value: parseInt(hex.substr(0, 2), 16) };
            rgb.green = { value: parseInt(hex.substr(2, 2), 16) };
            rgb.blue = { value: parseInt(hex.substr(4, 2), 16) };
            return rgb;
        }

        function getFromRGB(rgb) {
            var returnValue = {};
            if (rgb.indexOf('rgba(') >= 0) {
                rgb = rgb.replace('rgba(', '');
            } else {
                rgb = rgb.replace('rgb(', '');
            }
            rgb = rgb.replace(')', '').replace(/ /g, '').split(',');
            returnValue.red = { value: parseInt(rgb[0], 10) };
            returnValue.green = { value: parseInt(rgb[1], 10) };
            returnValue.blue = { value: parseInt(rgb[2], 10) };
            return returnValue;
        }

        function getColor(color) {
            var rgb = {};
            if (color.indexOf('#') >= 0) {
                return getFromHex(color);
            } else {
                return getFromRGB(color);
            }
        }

        function getHex(dec) {
            var hex = Math.round(dec).toString(16);
            if (hex.length < 2) {
                hex = '0' + hex;
            }
            return hex;
        }

        function getHexColor(rgb) {
            var red = getHex(rgb.red.value),
                green = getHex(rgb.green.value),
                blue = getHex(rgb.blue.value);
            return '#' + red + green + blue;
        }

        function getSteps() {
            var interval = options.interval,
                rgb = sysVars.rgbColor,
                rgbTarget = sysVars.rgbTargetColor;
            rgb.red.step = 10 * (rgbTarget.red.value - rgb.red.value) / interval;
            rgb.green.step = 10 * (rgbTarget.green.value - rgb.green.value) / interval;
            rgb.blue.step = 10 * (rgbTarget.blue.value - rgb.blue.value) / interval;
        }

        function startAnimation(element) {
            var rgb = sysVars.rgbColor;
            sysVars.timeout = setTimeout(function () {
                if (sysVars.currentInterval >= options.interval) {
                    clearTimeout(sysVars.timeout);
                    return;
                }
                sysVars.currentInterval += sysVars.animationStep;
                rgb.red.value += rgb.red.step;
                rgb.green.value += rgb.green.step;
                rgb.blue.value += rgb.blue.step;
                element.css(options.property, getHexColor(rgb));
                startAnimation(element);
            }, sysVars.animationStep);
        }

        return (function (userOptions) {
            $.extend(options, userOptions);
            sysVars.rgbTargetColor = getColor(options.color);
            sysVars.rgbColor = getColor(element.css(options.property));
            getSteps();
            startAnimation(element);
        }());
    };
}(jQuery));

The whole project you can see in my github repository: GitHub