Skip to content

Instantly share code, notes, and snippets.

⚡️
发电

DIYgod DIYgod

⚡️
发电
Block or report user

Report or block DIYgod

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@DIYgod
DIYgod / screenshot.js
Created Oct 11, 2019
HTML5 video screenshot
View screenshot.js
const canvas = document.createElement('canvas');
const video = document.querySelector('video');
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
let dataURL;
canvas.toBlob((blob) => {
dataURL = URL.createObjectURL(blob);
const link = document.createElement('a');
View gist:98d33aba4c035d85b5b6dc4449f2f080
const initEllipsis = (ele, height) => {
ele.each(function () {
var $this = $(this);
var text = $this.text();
var lastLength = text.length;
var destination = height;
$this.height('auto');
while ($this.height() > destination && lastLength > 0) {
View gist:53967895af30f1f720b2
// dotdotdot
function initEllipsis(ele, height) {
ele.each(function () {
var $this = $(this);
var text = $this.text();
var lastLength = text.length;
var destination = height;
$this.height('auto');
You can’t perform that action at this time.