Skip to content

Instantly share code, notes, and snippets.

View DIYgod's full-sized avatar
发电

DIYgod DIYgod

发电
View GitHub Profile
@DIYgod
DIYgod / screenshot.js
Last active February 10, 2020 17:50
HTML5 video screenshot
canvas = document.createElement('canvas');
video = document.querySelector('video');
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
canvas.toBlob((blob) => {
dataURL = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = dataURL;
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) {
// 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');