在Meteor中使用Jquery-waypoints

时间:2015-03-10 23:04:34

标签: jquery meteor jquery-waypoints

我试图使用流星开发者组的包来使用jquery航点。我只是尝试从入门文档中做最简单的航点。

var waypoint = new Waypoint({
    element: document.getElementById('tester'),
    handler: function(direction) {
        alert('direction: ' + direction);
    }
});

当我去localhost时,它说“未被引用的引用;没有定义Waypoint”但是当我查看header标签时,包含了waypoints并且它包含在jquery之后?

2 个答案:

答案 0 :(得分:1)

收到相同的错误消息后,在尝试下面的两个包之后:

meteor添加jquery-waypoints ..和 meteor add mrt:jquery-waypoints2

既没有奏效,也收到了同样的消息。但是,我安装了下面的软件包,功能也很好。

class ConversionClass
{
    private static Dictionary<int, string> InitialNumbers = new Dictionary<int, string>();
    private static Dictionary<int, string> MultipleOfTen = new Dictionary<int, string>();
    private static Dictionary<int, string> MultipleOfHundered = new Dictionary<int, string>();

    private static void InitializeStatic()
    {
        //InitialNumbers.Add(0, "zero");
        InitialNumbers.Add(1, "one");
        InitialNumbers.Add(2, "two");
        InitialNumbers.Add(3, "three");
        InitialNumbers.Add(4, "four");
        InitialNumbers.Add(5, "five");
        InitialNumbers.Add(6, "six");
        InitialNumbers.Add(7, "seven");
        InitialNumbers.Add(8, "eight");
        InitialNumbers.Add(9, "nine");
        InitialNumbers.Add(10, "ten");
        InitialNumbers.Add(11, "eleven");
        InitialNumbers.Add(12, "tweleve");
        InitialNumbers.Add(13, "thirteen");
        InitialNumbers.Add(14, "fourteen");
        InitialNumbers.Add(15, "fifteen");
        InitialNumbers.Add(16, "sixteen");
        InitialNumbers.Add(17, "seventeen");
        InitialNumbers.Add(18, "eighteen");
        InitialNumbers.Add(19, "nineteen");

        MultipleOfTen.Add(1, "ten");
        MultipleOfTen.Add(2, "twenty");
        MultipleOfTen.Add(3, "thirty");
        MultipleOfTen.Add(4, "fourty");
        MultipleOfTen.Add(5, "fifty");
        MultipleOfTen.Add(6, "sixty");
        MultipleOfTen.Add(7, "seventy");
        MultipleOfTen.Add(8, "eighty");
        MultipleOfTen.Add(9, "ninety");

        MultipleOfHundered.Add(2, "hundred");                      //                100
        MultipleOfHundered.Add(3, "thousand");                     //              1 000
        MultipleOfHundered.Add(4, "thousand");                     //             10 000
        MultipleOfHundered.Add(5, "thousand");                     //            100 000
        MultipleOfHundered.Add(6, "million");                      //          1 000 000
        MultipleOfHundered.Add(7, "million");                      //        100 000 000
        MultipleOfHundered.Add(8, "million");                      //      1 000 000 000
        MultipleOfHundered.Add(9, "billion");                      //  1 000 000 000 000
    }

    public static void Main()
    {
        InitializeStatic();
        Console.WriteLine("Enter number :");
        var userInput = Console.ReadLine();
        double userValue ;
        if (double.TryParse(userInput, out userValue))  // userValue = 193524019.50
        {
            int decimalPortion = (int)userValue;
            //var fractionPortion = Math.Ceiling(((userValue < 1.0) ? userValue : (userValue % Math.Floor(userValue))) * 100);
            int fractionPortion = (int)(userValue * 100) - ((int)userValue * 100);

            int digit; int power;
            StringBuilder numberInText = new StringBuilder();

            while (decimalPortion > 0)
            {
                GetDigitAndPower(decimalPortion, out digit, out power);
                numberInText.Append(ConvertToText(ref decimalPortion, ref digit, ref power));
                if (decimalPortion > 0)
                {
                    decimalPortion = GetReminder(decimalPortion, digit, power);
                }
            }
            numberInText.Append(" point ");
            while (fractionPortion > 0)
            {
                GetDigitAndPower(fractionPortion, out digit, out power);
                numberInText.Append(ConvertToText(ref fractionPortion, ref digit, ref power));
                if (fractionPortion > 0)
                {
                    fractionPortion = GetReminder(fractionPortion, digit, power);
                }
            }

            Console.WriteLine(numberInText.ToString());
        }
        Console.ReadKey();
    }

    private static int GetReminder(int orgValue, int digit, int power)
    {
        int returningValue = orgValue - (digit * (int)Math.Pow(10, power));
        return returningValue;
    }

    private static void GetDigitAndPower(int originalValue, out int digit, out int power)
    {
        for (power = 0, digit = 0; power < 10; power++)
        {
            var divisionFactor = (int)Math.Pow(10, power);
            int operationalValue = (originalValue / divisionFactor);
            if (operationalValue <= 0)
            {
                power = power - 1;
                digit = (int)(originalValue / Math.Pow(10, power));
                break;
            }
        } 
    }

    private static string ConvertToText(ref int orgValue, ref int digit, ref int power)
    {
        string numberToText = string.Empty;

        if (power < 2)
        {
            if (InitialNumbers.ContainsKey(orgValue))
            {
                //This is for number 1 to 19
                numberToText = InitialNumbers[orgValue];
                orgValue = 0;
            }
            else if (MultipleOfTen.ContainsKey(digit))
            {
                //This is for multiple of 10 (20,30,..90)
                numberToText = MultipleOfTen[digit];
            }
        }
        else
        {
            if (power < 4)
            {
                numberToText = string.Format("{0} {1}", InitialNumbers[digit], MultipleOfHundered[power]);
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                int multiplicationFactor = power / 3;
                int innerOrgValue = (int) (orgValue / Math.Pow(10, (multiplicationFactor * 3)));
                digit = innerOrgValue;
                var multiple = MultipleOfHundered[power];
                power = power - ((int)Math.Ceiling(Math.Log10(innerOrgValue)) - 1);

                int innerPower = 0;
                int innerDigit = 0;
                while (innerOrgValue > 0)
                {
                    GetDigitAndPower(innerOrgValue, out innerDigit, out innerPower);
                    var text = ConvertToText(ref innerOrgValue, ref innerDigit, ref innerPower);
                    sb.Append(text);
                    sb.Append(" ");
                    if (innerOrgValue > 0)
                    {
                        innerOrgValue = GetReminder(innerOrgValue, innerDigit, innerPower);
                    }
                }
                sb.Append(multiple);
                numberToText = sb.ToString();

            }
        }

        return numberToText + " ";
    }

}

以下代码适用于已安装的软件包。

meteor add bigu:waypoints

仍然无法弄清楚对方官员的错误是什么?&#39;包,但我希望这会有所帮助。

答案 1 :(得分:0)

看起来好像没有安装航点。如果你正在使用流星,那么你可能已经有了npm:

转到终端并键入

npm install waypoints

或者如果你有凉亭

bower install waypoints

只是为了确保你已经安装了它,运行:

npm list

你应该在那里看到它