npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

weapp-pixi-adapter

v0.2.0

Published

微信小游戏pixi.js适配器

Readme

weapp-adapter for pixi.js

编译

npm install
npm run build

主要改动

输出TouchEvent

官方的adapter并没有把TouchEvent绑定到window,改动也很简单。首先,修改src/EventIniter/TouchEvent.js把默认的TouchEvent类输出:

export default class TouchEvent {
	...
}

随后,修改src/window.js,将其输出即可:

export TouchEvent from './EventIniter/TouchEvent'

关于点击位置映射为题

pixi.js对元素的位置映射有特殊的处理,在其

InteractionManager.prototype.mapPositionToPoint = function mapPositionToPoint(point, x, y) {
        var rect = void 0;

        // IE 11 fix
        if (!this.interactionDOMElement.parentElement) {
            rect = { x: 0, y: 0, width: 0, height: 0 };
        } else {
            rect = this.interactionDOMElement.getBoundingClientRect();
        }

        var resolutionMultiplier = navigator.isCocoonJS ? this.resolution : 1.0 / this.resolution;

        point.x = (x - rect.left) * (this.interactionDOMElement.width / rect.width) * resolutionMultiplier;
        point.y = (y - rect.top) * (this.interactionDOMElement.height / rect.height) * resolutionMultiplier;
    };

会对interactionDOMElementparentElement进行检测,这里的interactionDOMElement元素就是weapp-adapter输出的canvas元素,显然其parentElement元素总是为空的,因此,上述函数总是返回空的区域,为了解决这个问题,有两种方法,一种就是直接覆盖这个函数自己想法重新映射:

PIXI.interaction.InteractionManager.prototype.mapPositionToPoint = (point, x, y) => {
    point.x = x * pixelRatio
    point.y = y * pixelRatio
}

或者

app.renderer.plugins.interaction.mapPositionToPoint = (point, x, y) => {
    point.x = x * pixelRatio
    point.y = y * pixelRatio
}

另外一种就是修改weapp-adaptercanvas对象,将其parentElement设置为true。在src/Canvas.js文件中,增加:

// pixi.js mapPositionToPoint hack
  canvas.__proto__.parentElement = true

这里采用第二种方式。

ajax相关问题

PIXI.loaderajax相关的问题,在src/XMLHttpRequest.js中增加:

addEventListener(ev, cb) {
  this[`on${ev}`] = cb
}